Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-19 05:05:21
Exec Total Coverage
Lines: 1478 3927 37.6%
Functions: 123 338 36.4%
Branches: 785 2820 27.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 14 void load_game_configs()
279 {
280 14 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 14 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 14 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 14 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 14 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 14 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 14 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 14 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 14 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 14 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 14 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 14 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 14 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 14 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 14 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 14 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 14 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 14 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 14 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 14 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 14 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 14 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 14 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 14 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 14 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 14 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 14 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 14 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 14 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 14 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 14 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 14 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 14 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 14 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 14 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 14 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 14 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 14 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 14 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 14 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 14 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 14 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 14 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 14 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 14 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 14 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 14 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 14 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 14 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 14 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 14 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 14 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 14 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 14 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 14 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 14 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 14 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 14 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 14 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 14 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 14 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 14 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 14 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 14 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 14 title_version = zc_get_config(cfg_sect,"title",2);
360 14 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 14 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 14 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 14 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 14 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 14 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 14 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 14 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 14 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 14 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 14 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 14 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 14 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 14 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 14 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403 14 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
404
405 14 char const* default_path = "";
406 14 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
407
408
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(strlen(qstdir)==0)
409 {
410 14 getcwd(qstdir,2048);
411 14 fix_filename_case(qstdir);
412 14 fix_filename_slashes(qstdir);
413 14 put_backslash(qstdir);
414 14 }
415 else
416 {
417 chop_path(qstdir);
418 }
419
420 14 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
421 14 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
422 14 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
423 14 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
424 14 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
425 14 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
426 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
427 14 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
428 14 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
429 14 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
430 14 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
431 14 }
432
433 void save_control_configs(bool kb)
434 {
435 if(kb)
436 {
437 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
438 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
440 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
441
442 if (!replay_is_replaying())
443 {
444 zc_set_config(ctrl_sect,"key_a",Akey);
445 zc_set_config(ctrl_sect,"key_b",Bkey);
446 zc_set_config(ctrl_sect,"key_s",Skey);
447 zc_set_config(ctrl_sect,"key_l",Lkey);
448 zc_set_config(ctrl_sect,"key_r",Rkey);
449 zc_set_config(ctrl_sect,"key_p",Pkey);
450 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
451 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
452 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
453 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
454 zc_set_config(ctrl_sect,"key_up", DUkey);
455 zc_set_config(ctrl_sect,"key_down", DDkey);
456 zc_set_config(ctrl_sect,"key_left", DLkey);
457 zc_set_config(ctrl_sect,"key_right",DRkey);
458 }
459 }
460 else
461 {
462 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
463 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
464 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
465 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
466 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
467 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
468 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
469 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
470 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
471 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
472 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
473 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
474 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
475 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
476
477 zc_set_config(ctrl_sect,"btn_a",Abtn);
478 zc_set_config(ctrl_sect,"btn_b",Bbtn);
479 zc_set_config(ctrl_sect,"btn_s",Sbtn);
480 zc_set_config(ctrl_sect,"btn_m",Mbtn);
481 zc_set_config(ctrl_sect,"btn_l",Lbtn);
482 zc_set_config(ctrl_sect,"btn_r",Rbtn);
483 zc_set_config(ctrl_sect,"btn_p",Pbtn);
484 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
485 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
486 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
487 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
488
489 zc_set_config(ctrl_sect,"btn_up",DUbtn);
490 zc_set_config(ctrl_sect,"btn_down",DDbtn);
491 zc_set_config(ctrl_sect,"btn_left",DLbtn);
492 zc_set_config(ctrl_sect,"btn_right",DRbtn);
493 }
494 }
495
496 void save_game_configs()
497 {
498 packfile_password("");
499
500 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
501
502 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
503 {
504 int o_window_x, o_window_y;
505 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
506 zc_set_config(cfg_sect,"window_x",o_window_x);
507 zc_set_config(cfg_sect,"window_y",o_window_y);
508 }
509
510 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
511 {
512 double monitor_scale = zc_get_monitor_scale();
513 window_width = al_get_display_width(all_get_display()) / monitor_scale;
514 window_height = al_get_display_height(all_get_display()) / monitor_scale;
515 zc_set_config(cfg_sect,"window_width",window_width);
516 zc_set_config(cfg_sect,"window_height",window_height);
517 }
518
519 zc_set_config(cfg_sect,"load_last",loadlast);
520 chop_path(qstdir);
521 zc_set_config(cfg_sect,qst_dir_name,qstdir);
522 zc_set_config("SAVEFILE","save_filename",save_file_name);
523 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
524 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
525
526 flush_config_file();
527 #ifdef __EMSCRIPTEN__
528 em_sync_fs();
529 #endif
530 }
531
532 //----------------------------------------------------------------
533
534 // Timers
535
536 13984 void fps_callback()
537 {
538 13984 lastfps=framecnt;
539 13984 dword tempsecs = fps_secs;
540 13984 ++tempsecs;
541 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
542 13984 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
543 13984 ++fps_secs;
544 13984 framecnt=0;
545 13984 }
546
547 END_OF_FUNCTION(fps_callback)
548
549 14 int32_t Z_init_timers()
550 {
551 static bool didit = false;
552 const static char *err_str = "Couldn't allocate timer";
553 14 err_str = err_str; //Unused variable warning
554
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(didit)
556 return 1;
557
558 14 didit = true;
559
560 LOCK_VARIABLE(lastfps);
561 LOCK_VARIABLE(framecnt);
562 LOCK_FUNCTION(fps_callback);
563
564
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
565 return 0;
566
567 14 return 1;
568 14 }
569
570 void Z_remove_timers()
571 {
572 remove_int(fps_callback);
573 }
574
575 //----------------------------------------------------------------
576
577 void go()
578 {
579 scare_mouse();
580 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
581 unscare_mouse();
582 }
583
584 void comeback()
585 {
586 scare_mouse();
587 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
588 unscare_mouse();
589 }
590
591 void dump_pal(BITMAP *dest)
592 {
593 for(int32_t i=0; i<256; i++)
594 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
595 }
596
597 //----------------------------------------------------------------
598
599 //Handles converting the mouse sprite from the .dat file
600 14 void load_mouse()
601 {
602 14 system_pal();
603 14 scare_mouse();
604 14 set_mouse_sprite(NULL);
605
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
606
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
70 for(int32_t j = 0; j < 4; ++j)
607 {
608 56 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
609 56 BITMAP* subbmp = create_bitmap_ex(8,16,16);
610
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(zcmouse[j])
611 destroy_bitmap(zcmouse[j]);
612 56 zcmouse[j] = create_bitmap_ex(8,sz,sz);
613 56 clear_bitmap(zcmouse[j]);
614 56 clear_bitmap(tmpbmp);
615 56 clear_bitmap(subbmp);
616 56 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
617
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 56 times.
952 for(int32_t x = 0; x < 16; ++x)
618 {
619
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 896 times.
15232 for(int32_t y = 0; y < 16; ++y)
620 {
621 14336 int32_t color = getpixel(tmpbmp, x, y);
622
5/5
✓ Branch 0 taken 13188 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 308 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 252 times.
14336 switch(color)
623 {
624 case dvc(1):
625 266 color = jwin_pal[jcCURSORMISC];
626 266 break;
627 case dvc(2):
628 308 color = jwin_pal[jcCURSOROUTLINE];
629 308 break;
630 case dvc(3):
631 322 color = jwin_pal[jcCURSORLIGHT];
632 322 break;
633 case dvc(5):
634 252 color = jwin_pal[jcCURSORDARK];
635 252 break;
636 }
637 14336 putpixel(subbmp, x, y, color);
638 14336 }
639 896 }
640
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(sz!=16)
641 56 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
642 else
643 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
644 56 destroy_bitmap(tmpbmp);
645 56 destroy_bitmap(subbmp);
646 56 }
647 14 set_mouse_sprite(zcmouse[0]);
648
649 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
650 14 set_palette(*hw_palette);
651 14 show_mouse(screen);
652 14 show_mouse(NULL);
653
654 14 unscare_mouse();
655 14 game_pal();
656 14 }
657
658 // sets the video mode and initializes the palette and mouse sprite
659 14 bool game_vid_mode(int32_t mode,int32_t wait)
660 {
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
662 {
663 return false;
664 }
665
666 14 scrx = (resx-320)>>1;
667 14 scry = (resy-240)>>1;
668
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
70 for(int32_t q = 0; q < 4; ++q)
669 56 zcmouse[q] = NULL;
670 14 load_mouse();
671 14 set_mouse_sprite(zcmouse[0]);
672
673
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 14 times.
238 for(int32_t i=240; i<256; i++)
674 224 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
675
676 14 set_palette(RAMpal);
677 14 clear_to_color(screen,BLACK);
678
679 14 rest(wait);
680 14 return true;
681 14 }
682
683 3 void null_quest()
684 {
685 char qstdat_string[2048];
686 3 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
687 3 strcat(qstdat_string,"#NESQST_NEW_QST");
688
689 #ifdef __EMSCRIPTEN__
690 // The quest template data file is not included because it's really big and isn't really needed
691 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
692 // which is much smaller.
693 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
694 #endif
695
696 3 byte skip_flags[4] = { 0 };
697
698 3 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
699 3 }
700
701 3 void init_NES_mode()
702 {
703 /*
704 // qst.dat may not load correctly without this...
705 QHeader.templatepath[0]='\0';
706
707 if(!init_colordata(true, &QHeader, &QMisc))
708 {
709 return;
710 }
711
712 loadfullpal();
713 init_tiles(false, &QHeader);
714 */
715 3 null_quest();
716 3 }
717
718 //----------------------------------------------------------------
719
720 qword trianglelines[16]=
721 {
722 0x0000000000000000ULL,
723 0xFD00000000000000ULL,
724 0xFDFD000000000000ULL,
725 0xFDFDFD0000000000ULL,
726 0xFDFDFDFD00000000ULL,
727 0xFDFDFDFDFD000000ULL,
728 0xFDFDFDFDFDFD0000ULL,
729 0xFDFDFDFDFDFDFD00ULL,
730 0xFDFDFDFDFDFDFDFDULL,
731 0x00FDFDFDFDFDFDFDULL,
732 0x0000FDFDFDFDFDFDULL,
733 0x000000FDFDFDFDFDULL,
734 0x00000000FDFDFDFDULL,
735 0x0000000000FDFDFDULL,
736 0x000000000000FDFDULL,
737 0x00000000000000FDULL,
738 };
739
740 word screen_triangles[28][32];
741 /*
742 qword triangles[4][16]= //[direction][value]
743 {
744 {
745 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
746 },
747 {
748 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
749 },
750 {
751 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
752 },
753 {
754 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
755 }
756 };
757 */
758
759
760 /*
761 byte triangles[4][16][8]= //[direction][value][line]
762 {
763 {
764 {
765 0, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 1, 0, 0, 0, 0, 0, 0, 0
769 },
770 {
771 2, 1, 0, 0, 0, 0, 0, 0
772 },
773 {
774 3, 2, 1, 0, 0, 0, 0, 0
775 },
776 {
777 4, 3, 2, 1, 0, 0, 0, 0
778 },
779 {
780 5, 4, 3, 2, 1, 0, 0, 0
781 },
782 {
783 6, 5, 4, 3, 2, 1, 0, 0
784 },
785 {
786 7, 6, 5, 4, 3, 2, 1, 0
787 },
788 {
789 8, 7, 6, 5, 4, 3, 2, 1
790 },
791 {
792 8, 8, 7, 6, 5, 4, 3, 2
793 },
794 {
795 8, 8, 8, 7, 6, 5, 4, 3
796 },
797 {
798 8, 8, 8, 8, 7, 6, 5, 4
799 },
800 {
801 8, 8, 8, 8, 8, 7, 6, 5
802 },
803 {
804 8, 8, 8, 8, 8, 8, 7, 6
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 7
808 },
809 {
810 8, 8, 8, 8, 8, 8, 8, 8
811 }
812 },
813 {
814 {
815 0, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 15, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 14, 15, 0, 0, 0, 0, 0, 0
822 },
823 {
824 13, 14, 15, 0, 0, 0, 0, 0
825 },
826 {
827 12, 13, 14, 15, 0, 0, 0, 0
828 },
829 {
830 11, 12, 13, 14, 15, 0, 0, 0
831 },
832 {
833 10, 11, 12, 13, 14, 15, 0, 0
834 },
835 {
836 9, 10, 11, 12, 13, 14, 15, 0
837 },
838 {
839 8, 9, 10, 11, 12, 13, 14, 15
840 },
841 {
842 8, 8, 9, 10, 11, 12, 13, 14
843 },
844 {
845 8, 8, 8, 9, 10, 11, 12, 13
846 },
847 {
848 8, 8, 8, 8, 9, 10, 11, 12
849 },
850 {
851 8, 8, 8, 8, 8, 9, 10, 11
852 },
853 {
854 8, 8, 8, 8, 8, 8, 9, 10
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 9
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 8
861 }
862 },
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 0, 0, 0, 0, 0, 0, 0, 1
869 },
870 {
871 0, 0, 0, 0, 0, 0, 1, 2
872 },
873 {
874 0, 0, 0, 0, 0, 1, 2, 3
875 },
876 {
877 0, 0, 0, 0, 1, 2, 3, 4
878 },
879 {
880 0, 0, 0, 1, 2, 3, 4, 5
881 },
882 {
883 0, 0, 1, 2, 3, 4, 5, 6
884 },
885 {
886 0, 1, 2, 3, 4, 5, 6, 7
887 },
888 {
889 1, 2, 3, 4, 5, 6, 7, 8
890 },
891 {
892 2, 3, 4, 5, 6, 7, 8, 8
893 },
894 {
895 3, 4, 5, 6, 7, 8, 8, 8
896 },
897 {
898 4, 5, 6, 7, 8, 8, 8, 8
899 },
900 {
901 5, 6, 7, 8, 8, 8, 8, 8
902 },
903 {
904 6, 7, 8, 8, 8, 8, 8, 8
905 },
906 {
907 7, 8, 8, 8, 8, 8, 8, 8
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 0, 0, 0, 0, 0, 0, 0, 15
919 },
920 {
921 0, 0, 0, 0, 0, 0, 15, 14
922 },
923 {
924 0, 0, 0, 0, 0, 15, 14, 13
925 },
926 {
927 0, 0, 0, 0, 15, 14, 13, 12
928 },
929 {
930 0, 0, 0, 15, 14, 13, 12, 11
931 },
932 {
933 0, 0, 15, 14, 13, 12, 11, 10
934 },
935 {
936 0, 15, 14, 13, 12, 11, 10, 9
937 },
938 {
939 15, 14, 13, 12, 11, 10, 9, 8
940 },
941 {
942 14, 13, 12, 11, 10, 9, 8, 8
943 },
944 {
945 13, 12, 11, 10, 9, 8, 8, 8
946 },
947 {
948 12, 11, 10, 9, 8, 8, 8, 8
949 },
950 {
951 11, 10, 9, 8, 8, 8, 8, 8
952 },
953 {
954 10, 9, 8, 8, 8, 8, 8, 8
955 },
956 {
957 9, 8, 8, 8, 8, 8, 8, 8
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 }
963 };
964 */
965
966
967
968 /*
969 for (int32_t blockrow=0; blockrow<30; ++i)
970 {
971 for (int32_t linerow=0; linerow<8; ++i)
972 {
973 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
974 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
975 {
976 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
977 ++triangleline;
978 }
979 }
980 }
981 */
982
983 // the ULL suffixes are to prevent this warning:
984 // warning: integer constant is too large for "int32_t" type
985
986 qword triangles[4][16][8]= //[direction][value][line]
987 {
988 {
989 {
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL
998 },
999 {
1000 0xFD00000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL
1008 },
1009 {
1010 0xFDFD000000000000ULL,
1011 0xFD00000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL
1018 },
1019 {
1020 0xFDFDFD0000000000ULL,
1021 0xFDFD000000000000ULL,
1022 0xFD00000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL
1028 },
1029 {
1030 0xFDFDFDFD00000000ULL,
1031 0xFDFDFD0000000000ULL,
1032 0xFDFD000000000000ULL,
1033 0xFD00000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL
1038 },
1039 {
1040 0xFDFDFDFDFD000000ULL,
1041 0xFDFDFDFD00000000ULL,
1042 0xFDFDFD0000000000ULL,
1043 0xFDFD000000000000ULL,
1044 0xFD00000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL
1048 },
1049 {
1050 0xFDFDFDFDFDFD0000ULL,
1051 0xFDFDFDFDFD000000ULL,
1052 0xFDFDFDFD00000000ULL,
1053 0xFDFDFD0000000000ULL,
1054 0xFDFD000000000000ULL,
1055 0xFD00000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL
1058 },
1059 {
1060 0xFDFDFDFDFDFDFD00ULL,
1061 0xFDFDFDFDFDFD0000ULL,
1062 0xFDFDFDFDFD000000ULL,
1063 0xFDFDFDFD00000000ULL,
1064 0xFDFDFD0000000000ULL,
1065 0xFDFD000000000000ULL,
1066 0xFD00000000000000ULL,
1067 0x0000000000000000ULL
1068 },
1069 {
1070 0xFDFDFDFDFDFDFDFDULL,
1071 0xFDFDFDFDFDFDFD00ULL,
1072 0xFDFDFDFDFDFD0000ULL,
1073 0xFDFDFDFDFD000000ULL,
1074 0xFDFDFDFD00000000ULL,
1075 0xFDFDFD0000000000ULL,
1076 0xFDFD000000000000ULL,
1077 0xFD00000000000000ULL
1078 },
1079 {
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFD00ULL,
1083 0xFDFDFDFDFDFD0000ULL,
1084 0xFDFDFDFDFD000000ULL,
1085 0xFDFDFDFD00000000ULL,
1086 0xFDFDFD0000000000ULL,
1087 0xFDFD000000000000ULL
1088 },
1089 {
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFD00ULL,
1094 0xFDFDFDFDFDFD0000ULL,
1095 0xFDFDFDFDFD000000ULL,
1096 0xFDFDFDFD00000000ULL,
1097 0xFDFDFD0000000000ULL
1098 },
1099 {
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFD00ULL,
1105 0xFDFDFDFDFDFD0000ULL,
1106 0xFDFDFDFDFD000000ULL,
1107 0xFDFDFDFD00000000ULL
1108 },
1109 {
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFD00ULL,
1116 0xFDFDFDFDFDFD0000ULL,
1117 0xFDFDFDFDFD000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFD00ULL,
1127 0xFDFDFDFDFDFD0000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFD00ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL
1148 }
1149 },
1150 {
1151 {
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL
1160 },
1161 {
1162 0x00000000000000FDULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL
1170 },
1171 {
1172 0x000000000000FDFDULL,
1173 0x00000000000000FDULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL
1180 },
1181 {
1182 0x0000000000FDFDFDULL,
1183 0x000000000000FDFDULL,
1184 0x00000000000000FDULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL
1190 },
1191 {
1192 0x00000000FDFDFDFDULL,
1193 0x0000000000FDFDFDULL,
1194 0x000000000000FDFDULL,
1195 0x00000000000000FDULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL
1200 },
1201 {
1202 0x000000FDFDFDFDFDULL,
1203 0x00000000FDFDFDFDULL,
1204 0x0000000000FDFDFDULL,
1205 0x000000000000FDFDULL,
1206 0x00000000000000FDULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL
1210 },
1211 {
1212 0x0000FDFDFDFDFDFDULL,
1213 0x000000FDFDFDFDFDULL,
1214 0x00000000FDFDFDFDULL,
1215 0x0000000000FDFDFDULL,
1216 0x000000000000FDFDULL,
1217 0x00000000000000FDULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL
1220 },
1221 {
1222 0x00FDFDFDFDFDFDFDULL,
1223 0x0000FDFDFDFDFDFDULL,
1224 0x000000FDFDFDFDFDULL,
1225 0x00000000FDFDFDFDULL,
1226 0x0000000000FDFDFDULL,
1227 0x000000000000FDFDULL,
1228 0x00000000000000FDULL,
1229 0x0000000000000000ULL
1230 },
1231 {
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0x00FDFDFDFDFDFDFDULL,
1234 0x0000FDFDFDFDFDFDULL,
1235 0x000000FDFDFDFDFDULL,
1236 0x00000000FDFDFDFDULL,
1237 0x0000000000FDFDFDULL,
1238 0x000000000000FDFDULL,
1239 0x00000000000000FDULL
1240 },
1241 {
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0x00FDFDFDFDFDFDFDULL,
1245 0x0000FDFDFDFDFDFDULL,
1246 0x000000FDFDFDFDFDULL,
1247 0x00000000FDFDFDFDULL,
1248 0x0000000000FDFDFDULL,
1249 0x000000000000FDFDULL
1250 },
1251 {
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0x00FDFDFDFDFDFDFDULL,
1256 0x0000FDFDFDFDFDFDULL,
1257 0x000000FDFDFDFDFDULL,
1258 0x00000000FDFDFDFDULL,
1259 0x0000000000FDFDFDULL
1260 },
1261 {
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0x00FDFDFDFDFDFDFDULL,
1267 0x0000FDFDFDFDFDFDULL,
1268 0x000000FDFDFDFDFDULL,
1269 0x00000000FDFDFDFDULL
1270 },
1271 {
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0x00FDFDFDFDFDFDFDULL,
1278 0x0000FDFDFDFDFDFDULL,
1279 0x000000FDFDFDFDFDULL
1280 },
1281 {
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0x00FDFDFDFDFDFDFDULL,
1289 0x0000FDFDFDFDFDFDULL
1290 },
1291 {
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0x00FDFDFDFDFDFDFDULL
1300 },
1301 {
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0xFDFDFDFDFDFDFDFDULL
1310 }
1311 },
1312 {
1313 {
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL
1322 },
1323 {
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL
1332 },
1333 {
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL
1342 },
1343 {
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL
1352 },
1353 {
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL
1362 },
1363 {
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL
1372 },
1373 {
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL
1382 },
1383 {
1384 0x0000000000000000ULL,
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL
1392 },
1393 {
1394 0xFD00000000000000ULL,
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL
1402 },
1403 {
1404 0xFDFD000000000000ULL,
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL
1412 },
1413 {
1414 0xFDFDFD0000000000ULL,
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL
1422 },
1423 {
1424 0xFDFDFDFD00000000ULL,
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL
1432 },
1433 {
1434 0xFDFDFDFDFD000000ULL,
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL
1442 },
1443 {
1444 0xFDFDFDFDFDFD0000ULL,
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL
1452 },
1453 {
1454 0xFDFDFDFDFDFDFD00ULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL
1462 },
1463 {
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL,
1471 0xFDFDFDFDFDFDFDFDULL
1472 }
1473 },
1474 {
1475 {
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL
1484 },
1485 {
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL
1494 },
1495 {
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL
1504 },
1505 {
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL
1514 },
1515 {
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL
1524 },
1525 {
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL
1534 },
1535 {
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL
1544 },
1545 {
1546 0x0000000000000000ULL,
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL
1554 },
1555 {
1556 0x00000000000000FDULL,
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL
1564 },
1565 {
1566 0x000000000000FDFDULL,
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL
1574 },
1575 {
1576 0x0000000000FDFDFDULL,
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL
1584 },
1585 {
1586 0x00000000FDFDFDFDULL,
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL
1594 },
1595 {
1596 0x000000FDFDFDFDFDULL,
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL
1604 },
1605 {
1606 0x0000FDFDFDFDFDFDULL,
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL
1614 },
1615 {
1616 0x00FDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL
1624 },
1625 {
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL,
1633 0xFDFDFDFDFDFDFDFDULL
1634 }
1635 }
1636 };
1637
1638 int32_t black_opening_count=0;
1639 int32_t black_opening_x,black_opening_y;
1640 int32_t black_opening_shape;
1641
1642 371 int32_t choose_opening_shape()
1643 {
1644 // First, count how many bits are set
1645 371 int32_t numBits=0;
1646 int32_t bitCounter;
1647
1648
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 371 times.
2226 for(int32_t i=0; i<bosMAX; i++)
1649 {
1650
2/2
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 371 times.
1855 if(COOLSCROLL&(1<<i))
1651 371 numBits++;
1652 1855 }
1653
1654 // Shouldn't happen...
1655
1/2
✓ Branch 0 taken 371 times.
✗ Branch 1 not taken.
371 if(numBits==0)
1656 return bosCIRCLE;
1657
1658 // Pick a bit
1659 371 bitCounter=zc_rand()%numBits+1;
1660
1661
1/2
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
427 for(int32_t i=0; i<bosMAX; i++)
1662 {
1663 // If this bit is set, decrement the bit counter
1664
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 371 times.
427 if(COOLSCROLL&(1<<i))
1665 371 bitCounter--;
1666
1667 // When the counter hits 0, return a value based on
1668 // which bit it stopped on.
1669 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1670
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 56 times.
427 if(bitCounter==0)
1671 371 return i;
1672 56 }
1673
1674 // Shouldn't be necessary, but the compiler might complain, at least
1675 return bosCIRCLE;
1676 371 }
1677
1678 116 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1679 {
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1681
1682 116 int32_t w=256, h=224;
1683 116 int32_t blockrows=28, blockcolumns=32;
1684 116 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1685
1686
2/2
✓ Branch 0 taken 3248 times.
✓ Branch 1 taken 116 times.
3364 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1687 {
1688
2/2
✓ Branch 0 taken 103936 times.
✓ Branch 1 taken 3248 times.
107184 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1689 {
1690
2/2
✓ Branch 0 taken 55798 times.
✓ Branch 1 taken 48138 times.
103936 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1691 103936 }
1692 3248 }
1693
1694 116 black_opening_count = 66;
1695 116 black_opening_x = x;
1696 116 black_opening_y = y;
1697 116 lensclk = 0;
1698 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1699
1700
1701
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(black_opening_shape == bosFADEBLACK)
1702 {
1703 refreshTints();
1704 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1705 }
1706
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(wait)
1707 {
1708 FFCore.warpScriptCheck();
1709 for(int32_t i=0; i<66; i++)
1710 {
1711 draw_screen(tmpscr);
1712 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1713 syskeys();
1714 advanceframe(true);
1715
1716 if(Quit)
1717 {
1718 break;
1719 }
1720 }
1721 }
1722 116 }
1723
1724 255 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1725 {
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1727
1728 255 int32_t w=256, h=224;
1729 255 int32_t blockrows=28, blockcolumns=32;
1730 255 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1731
1732
2/2
✓ Branch 0 taken 7140 times.
✓ Branch 1 taken 255 times.
7395 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1733 {
1734
2/2
✓ Branch 0 taken 228480 times.
✓ Branch 1 taken 7140 times.
235620 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1735 {
1736
2/2
✓ Branch 0 taken 110104 times.
✓ Branch 1 taken 118376 times.
228480 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1737 228480 }
1738 7140 }
1739
1740 255 black_opening_count = -66;
1741 255 black_opening_x = x;
1742 255 black_opening_y = y;
1743 255 lensclk = 0;
1744
1/2
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
255 if(black_opening_shape == bosFADEBLACK)
1745 {
1746 refreshTints();
1747 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1748 }
1749
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 158 times.
255 if(wait)
1750 {
1751 158 FFCore.warpScriptCheck();
1752
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 10428 times.
10586 for(int32_t i=0; i<66; i++)
1753 {
1754 10428 draw_screen(tmpscr);
1755 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1756 10428 syskeys();
1757 10428 advanceframe(true);
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10428 times.
10428 if(Quit)
1760 {
1761 break;
1762 }
1763 10428 }
1764 158 }
1765 255 }
1766
1767 24486 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1768 {
1769 24486 clear_to_color(tmp_scr,BLACK);
1770 24486 int32_t w=256, h=224;
1771
1772
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 1188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23232 times.
24486 switch(black_opening_shape)
1773 {
1774 case bosOVAL:
1775 {
1776 double new_w=(w/2)+abs(w/2-x);
1777 double new_h=(h/2)+abs(h/2-y);
1778 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1779 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1780 break;
1781 }
1782
1783 case bosTRIANGLE:
1784 {
1785 66 double new_w=(w/2)+abs(w/2-x);
1786 66 double new_h=(h/2)+abs(h/2-y);
1787 66 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1788 66 double P2= (PI/2);
1789 66 double P23=(2*PI/3);
1790 66 double P43=(4*PI/3);
1791 66 double Pa= (-4*PI*a/(3*max_a));
1792 66 double angle=P2+Pa;
1793 66 double a0=angle;
1794 66 double a2=angle+P23;
1795 66 double a4=angle+P43;
1796 132 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1797 66 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1798 66 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1799 0);
1800 66 break;
1801 }
1802
1803 case bosSMAS:
1804 {
1805
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 726 times.
1188 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1806
1807
2/2
✓ Branch 0 taken 33264 times.
✓ Branch 1 taken 1188 times.
34452 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 266112 times.
✓ Branch 1 taken 33264 times.
299376 for(int32_t linerow=0; linerow<8; ++linerow)
1810 {
1811 266112 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1812
1813
2/2
✓ Branch 0 taken 8515584 times.
✓ Branch 1 taken 266112 times.
8781696 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1814 {
1815 25546752 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1816
6/6
✓ Branch 0 taken 5921664 times.
✓ Branch 1 taken 2593920 times.
✓ Branch 2 taken 5617144 times.
✓ Branch 3 taken 2898440 times.
✓ Branch 4 taken 3023224 times.
✓ Branch 5 taken 2593920 times.
8515584 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1817 8515584 [linerow];
1818 8515584 ++triangleline;
1819
1820
2/2
✓ Branch 0 taken 7451136 times.
✓ Branch 1 taken 1064448 times.
8515584 if(linerow==0)
1821 {
1822 1064448 }
1823 8515584 }
1824 266112 }
1825 33264 }
1826
1827 1188 break;
1828 }
1829
1830 case bosFADEBLACK:
1831 {
1832 if(black_opening_count<0)
1833 {
1834 black_fade(zc_min(-black_opening_count,63));
1835 }
1836 else if(black_opening_count>0)
1837 {
1838 black_fade(63-zc_max(black_opening_count-3,0));
1839 }
1840 else black_fade(0);
1841 return; //no blitting from tmp_scr!
1842 }
1843
1844 23232 case bosCIRCLE:
1845 default:
1846 {
1847 23232 double new_w=(w/2)+abs(w/2-x);
1848 23232 double new_h=(h/2)+abs(h/2-y);
1849 23232 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1850 //circlefill(tmp_scr,x,y,a<<3,0);
1851 23232 circlefill(tmp_scr,x,y,r,0);
1852 23232 break;
1853 }
1854 }
1855
1856 24486 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1857 24486 }
1858
1859
1860 void black_fade(int32_t fadeamnt)
1861 {
1862 for(int32_t i=0; i < 0xEF; i++)
1863 {
1864 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1865 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1866 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1867 }
1868
1869 refreshpal = true;
1870 }
1871
1872 //----------------------------------------------------------------
1873
1874 11782066 bool item_disabled(int32_t item) //is this item disabled?
1875 {
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11782066 times.
11782066 return (item>=0 && game->items_off[item] != 0);
1877 }
1878
1879 2835320 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1880 {
1881
2/2
✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 2814560 times.
2835320 if(current_item(item_type, true) >=item)
1882 {
1883 20760 return true;
1884 }
1885
1886 2814560 return false;
1887 2835320 }
1888
1889 14173681 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1890 {
1891
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2070416 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536615 times.
✓ Branch 6 taken 7960234 times.
✓ Branch 7 taken 2590638 times.
✓ Branch 8 taken 15778 times.
14173681 switch(item_type)
1892 {
1893 case itype_bomb:
1894 case itype_sbomb:
1895 {
1896 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898 if(itemid == -1)
1899 return false;
1900
1901 return (game->get_item(itemid));
1902 }
1903
1904 case itype_clock:
1905 {
1906 2070416 int32_t itemid = getItemID(itemsbuf, item_type, it);
1907
1908
2/4
✓ Branch 0 taken 2070416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2070416 times.
✗ Branch 3 not taken.
2070416 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1909 return (game->get_item(itemid));
1910 2070416 return Hero.getClock()?1:0;
1911 }
1912
1913 case itype_key:
1914 return (game->get_keys()>0);
1915
1916 case itype_magiccontainer:
1917 return (game->get_maxmagic()>=game->get_mp_per_block());
1918
1919 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1920 {
1921
1/3
✓ Branch 0 taken 1536615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1536615 switch(it)
1922 {
1923 case -2:
1924 {
1925 for(int32_t i=0; i<MAXLEVELS; i++)
1926 {
1927 if(game->lvlitems[i]&liTRIFORCE)
1928 {
1929 return true;
1930 }
1931 }
1932
1933 return false;
1934 }
1935
1936 case -1:
1937 return (game->lvlitems[dlevel]&liTRIFORCE);
1938
1939 default:
1940
2/4
✓ Branch 0 taken 1536615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1536615 times.
1536615 if(it>=0&&it<MAXLEVELS)
1941 {
1942 1536615 return (game->lvlitems[it]&liTRIFORCE);
1943 }
1944
1945 break;
1946 }
1947
1948 return 0;
1949 }
1950
1951 case itype_map: //it: -2=any, -1=current level, other=that level
1952 {
1953
1/3
✓ Branch 0 taken 7960234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7960234 switch(it)
1954 {
1955 case -2:
1956 {
1957 for(int32_t i=0; i<MAXLEVELS; i++)
1958 {
1959 if(game->lvlitems[i]&liMAP)
1960 {
1961 return true;
1962 }
1963 }
1964
1965 return false;
1966 }
1967
1968 case -1:
1969 return (game->lvlitems[dlevel]&liMAP)!=0;
1970
1971 default:
1972
2/4
✓ Branch 0 taken 7960234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7960234 times.
7960234 if(it>=0&&it<MAXLEVELS)
1973 {
1974 7960234 return (game->lvlitems[it]&liMAP)!=0;
1975 }
1976
1977 break;
1978 }
1979
1980 return 0;
1981 }
1982
1983 case itype_compass: //it: -2=any, -1=current level, other=that level
1984 {
1985
1/3
✓ Branch 0 taken 2590638 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2590638 switch(it)
1986 {
1987 case -2:
1988 {
1989 for(int32_t i=0; i<MAXLEVELS; i++)
1990 {
1991 if(game->lvlitems[i]&liCOMPASS)
1992 {
1993 return true;
1994 }
1995 }
1996
1997 return false;
1998 }
1999
2000 case -1:
2001 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2002
2003 default:
2004
2/4
✓ Branch 0 taken 2590638 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2590638 times.
✗ Branch 3 not taken.
2590638 if(it>=0&&it<MAXLEVELS)
2005 {
2006 2590638 return (game->lvlitems[it]&liCOMPASS)!=0;
2007 }
2008
2009 break;
2010 }
2011 return 0;
2012 }
2013
2014 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2015 {
2016
1/3
✓ Branch 0 taken 15778 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
15778 switch(it)
2017 {
2018 case -2:
2019 {
2020 for(int32_t i=0; i<MAXLEVELS; i++)
2021 {
2022 if(game->lvlitems[i]&liBOSSKEY)
2023 {
2024 return true;
2025 }
2026 }
2027
2028 return false;
2029 }
2030
2031 case -1:
2032 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2033
2034 default:
2035
2/4
✓ Branch 0 taken 15778 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15778 times.
15778 if(it>=0&&it<MAXLEVELS)
2036 {
2037 15778 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2038 }
2039 break;
2040 }
2041 return 0;
2042 }
2043
2044 default:
2045 //it=(1<<(it-1));
2046 /*if (item_type>=itype_max)
2047 {
2048 system_pal();
2049 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2050 game_pal();
2051
2052 return false;
2053 }*/
2054 int32_t itemid = getItemID(itemsbuf, item_type, it);
2055
2056 if(itemid == -1)
2057 return false;
2058
2059 return game->get_item(itemid);
2060 }
2061 14173681 }
2062
2063
2064 35165522 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2065 {
2066
9/9
✓ Branch 0 taken 2070416 times.
✓ Branch 1 taken 18602194 times.
✓ Branch 2 taken 2070416 times.
✓ Branch 3 taken 2070416 times.
✓ Branch 4 taken 2070416 times.
✓ Branch 5 taken 2070416 times.
✓ Branch 6 taken 2070416 times.
✓ Branch 7 taken 2070416 times.
✓ Branch 8 taken 2070416 times.
35165522 switch(item_type)
2067 {
2068 case itype_clock:
2069 {
2070 2070416 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2071
2072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2070416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2070416 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2073 return itemsbuf[maxid].fam_type;
2074
2075 2070416 return has_item(itype_clock,1) ? 1 : 0;
2076 }
2077
2078 case itype_key:
2079 2070416 return game->get_keys();
2080
2081 case itype_lkey:
2082 2070416 return game->lvlkeys[get_dlevel()];
2083
2084 case itype_magiccontainer:
2085 2070416 return game->get_maxmagic()/game->get_mp_per_block();
2086
2087 case itype_triforcepiece:
2088 {
2089 2070416 int32_t count=0;
2090
2091
2/2
✓ Branch 0 taken 1060052992 times.
✓ Branch 1 taken 2070416 times.
1062123408 for(int32_t i=0; i<MAXLEVELS; i++)
2092 {
2093 1060052992 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2094 1060052992 }
2095
2096 2070416 return count;
2097 }
2098
2099 case itype_map:
2100 {
2101 2070416 int32_t count=0;
2102
2103
2/2
✓ Branch 0 taken 1060052992 times.
✓ Branch 1 taken 2070416 times.
1062123408 for(int32_t i=0; i<MAXLEVELS; i++)
2104 {
2105 1060052992 count+=(game->lvlitems[i]&liMAP)?1:0;
2106 1060052992 }
2107
2108 2070416 return count;
2109 }
2110
2111 case itype_compass:
2112 {
2113 2070416 int32_t count=0;
2114
2115
2/2
✓ Branch 0 taken 1060052992 times.
✓ Branch 1 taken 2070416 times.
1062123408 for(int32_t i=0; i<MAXLEVELS; i++)
2116 {
2117 1060052992 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2118 1060052992 }
2119
2120 2070416 return count;
2121 }
2122
2123 case itype_bosskey:
2124 {
2125 2070416 int32_t count=0;
2126
2127
2/2
✓ Branch 0 taken 1060052992 times.
✓ Branch 1 taken 2070416 times.
1062123408 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 1060052992 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2130 1060052992 }
2131
2132 2070416 return count;
2133 }
2134
2135 default:
2136 18602194 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2137
2138
2/2
✓ Branch 0 taken 3818682 times.
✓ Branch 1 taken 14783512 times.
18602194 if(maxid == -1)
2139 14783512 return 0;
2140
2141 3818682 return itemsbuf[maxid].fam_type;
2142 }
2143 35165522 }
2144
2145 32330202 int32_t current_item(int32_t item_type) //item currently being used
2146 {
2147 32330202 return current_item(item_type, true);
2148 }
2149
2150 14 std::map<int32_t, int32_t> itemcache;
2151
2152 // Not actually used by anything at the moment...
2153 void removeFromItemCache(int32_t itemid)
2154 {
2155 itemcache.erase(itemid);
2156 }
2157
2158 10239 void flushItemCache()
2159 {
2160 10239 itemcache.clear();
2161
2162 //also fix the active subscreen if items were deleted -DD
2163
1/2
✓ Branch 0 taken 10239 times.
✗ Branch 1 not taken.
10239 if(game != NULL)
2164 {
2165 10239 verifyBothWeapons();
2166 10239 load_Sitems(&QMisc);
2167 10239 }
2168 10239 }
2169
2170 // This is used often, so it should be as direct as possible.
2171 1166441577 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2172 {
2173
2/2
✓ Branch 0 taken 1134255379 times.
✓ Branch 1 taken 32186198 times.
1166441577 if(jinx_check)
2174 {
2175
4/4
✓ Branch 0 taken 18281831 times.
✓ Branch 1 taken 13904367 times.
✓ Branch 2 taken 14874805 times.
✓ Branch 3 taken 3407026 times.
32186198 if(!(HeroSwordClk() || HeroItemClk()))
2176 14874805 jinx_check = false; //not jinxed
2177 32186198 }
2178
4/4
✓ Branch 0 taken 1157296755 times.
✓ Branch 1 taken 9144822 times.
✓ Branch 2 taken 17187779 times.
✓ Branch 3 taken 1140108976 times.
1166441577 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2179 {
2180 1140108976 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2181
2182
2/2
✓ Branch 0 taken 1134882086 times.
✓ Branch 1 taken 5226890 times.
1140108976 if(res != itemcache.end())
2183 1134882086 return res->second;
2184 5226890 }
2185
2186 31559491 int32_t result = -1;
2187 31559491 int32_t highestlevel = -1;
2188
2189
2/2
✓ Branch 0 taken 8079229696 times.
✓ Branch 1 taken 31559491 times.
8110789187 for(int32_t i=0; i<MAXITEMS; i++)
2190 {
2191
5/6
✓ Branch 0 taken 686042664 times.
✓ Branch 1 taken 7393187032 times.
✓ Branch 2 taken 11465778 times.
✓ Branch 3 taken 674576886 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11465778 times.
8079229696 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2192 {
2193
4/4
✓ Branch 0 taken 2890954 times.
✓ Branch 1 taken 8574824 times.
✓ Branch 2 taken 884678 times.
✓ Branch 3 taken 10581100 times.
11465778 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2194 {
2195 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2196
2/2
✓ Branch 0 taken 10581032 times.
✓ Branch 1 taken 68 times.
10581100 if(!checkmagiccost(i))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2199 }
2200 10581032 }
2201
6/6
✓ Branch 0 taken 9639114 times.
✓ Branch 1 taken 1826596 times.
✓ Branch 2 taken 179744 times.
✓ Branch 3 taken 1646852 times.
✓ Branch 4 taken 1162657 times.
✓ Branch 5 taken 663939 times.
11465710 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2202 {
2203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663939 times.
663939 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2204 663939 continue;
2205 }
2206
2207
2/2
✓ Branch 0 taken 176045 times.
✓ Branch 1 taken 10625726 times.
10801771 if(itemsbuf[i].fam_type >= highestlevel)
2208 {
2209 10625726 highestlevel = itemsbuf[i].fam_type;
2210 10625726 result=i;
2211 10625726 }
2212 10801771 }
2213 8078565689 }
2214
2215
2/2
✓ Branch 0 taken 17311393 times.
✓ Branch 1 taken 14248098 times.
31559491 if(!jinx_check) //Can't cache jinx_check results
2216 14248098 itemcache[itemtype] = result;
2217 31559491 return result;
2218 1166441577 }
2219
2220 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2221 1149365826 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2222 {
2223 1149365826 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2224
2/2
✓ Branch 0 taken 15110447 times.
✓ Branch 1 taken 1134255379 times.
1149365826 if(!jinx_check) //If not already a jinx-immune-only check...
2225 {
2226 //And the player IS jinxed...
2227
4/4
✓ Branch 0 taken 1120536992 times.
✓ Branch 1 taken 13718387 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1117179628 times.
1134255379 if(HeroSwordClk() || HeroItemClk())
2228 {
2229 //Then do a jinx-immune-only check here
2230 17075751 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2231 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2232 //Should NOT need a compat rule, as this should always return -1 in old quests.
2233
2/2
✓ Branch 0 taken 797035 times.
✓ Branch 1 taken 16278716 times.
17075751 if(ret2 > -1) return ret2;
2234 16278716 }
2235 1133458344 }
2236 1148568791 return ret;
2237 1149365826 }
2238 8316722 int32_t current_item_power(int32_t itemtype)
2239 {
2240 8316722 int32_t result = current_item_id(itemtype,true);
2241
2/2
✓ Branch 0 taken 5088762 times.
✓ Branch 1 taken 3227960 times.
8316722 return (result<0) ? 0 : itemsbuf[result].power;
2242 }
2243
2244 4 int32_t heart_container_id()
2245 {
2246
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 if(itemsbuf[i].family == itype_heartcontainer)
2249 {
2250 4 return i;
2251 }
2252 112 }
2253 return -1;
2254 4 }
2255
2256 2070416 int32_t item_tile_mod()
2257 {
2258 2070416 int32_t tile=0;
2259
2260
2/2
✓ Branch 0 taken 74626 times.
✓ Branch 1 taken 1995790 times.
2070416 if(game->get_bombs())
2261 {
2262 1995790 int32_t itemid = current_item_id(itype_bomb,false);
2263
3/4
✓ Branch 0 taken 1914731 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1914731 times.
1995790 if(itemid > -1 && checkbunny(itemid))
2264 1914731 tile+=itemsbuf[itemid].ltm;
2265 1995790 }
2266
2267
2/2
✓ Branch 0 taken 1631627 times.
✓ Branch 1 taken 438789 times.
2070416 if(game->get_sbombs())
2268 {
2269 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2270
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2271 437361 tile+=itemsbuf[itemid].ltm;
2272 438789 }
2273
2274
2/2
✓ Branch 0 taken 2023836 times.
✓ Branch 1 taken 46580 times.
2070416 if(current_item(itype_clock))
2275 {
2276 46580 int32_t itemid =
2277
1/2
✓ Branch 0 taken 46580 times.
✗ Branch 1 not taken.
46580 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iClock
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2280
2/4
✓ Branch 0 taken 46580 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46580 times.
46580 if(itemid > -1 && checkbunny(itemid))
2281 46580 tile+=itemsbuf[itemid].ltm;
2282 46580 }
2283
2284
2/2
✓ Branch 0 taken 1530092 times.
✓ Branch 1 taken 540324 times.
2070416 if(current_item(itype_key))
2285 {
2286 540324 int32_t itemid =
2287
1/2
✓ Branch 0 taken 540324 times.
✗ Branch 1 not taken.
540324 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iKey
2289 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2290
2/4
✓ Branch 0 taken 540324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540324 times.
540324 if(itemid > -1 && checkbunny(itemid))
2291 540324 tile+=itemsbuf[itemid].ltm;
2292 540324 }
2293
2294
2/2
✓ Branch 0 taken 1950709 times.
✓ Branch 1 taken 119707 times.
2070416 if(current_item(itype_lkey))
2295 {
2296 119707 int32_t itemid =
2297
2/2
✓ Branch 0 taken 118797 times.
✓ Branch 1 taken 910 times.
119707 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iLevelKey
2299 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2300
2/4
✓ Branch 0 taken 119707 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119707 times.
119707 if(itemid > -1 && checkbunny(itemid))
2301 119707 tile+=itemsbuf[itemid].ltm;
2302 119707 }
2303
2304
2/2
✓ Branch 0 taken 227916 times.
✓ Branch 1 taken 1842500 times.
2070416 if(current_item(itype_map))
2305 {
2306 1842500 int32_t itemid =
2307
2/2
✓ Branch 0 taken 1841714 times.
✓ Branch 1 taken 786 times.
1842500 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iMap
2309 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2310
2/4
✓ Branch 0 taken 1842500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1842500 times.
1842500 if(itemid > -1 && checkbunny(itemid))
2311 1842500 tile+=itemsbuf[itemid].ltm;
2312 1842500 }
2313
2314
2/2
✓ Branch 0 taken 84536 times.
✓ Branch 1 taken 1985880 times.
2070416 if(current_item(itype_compass))
2315 {
2316 1985880 int32_t itemid =
2317
2/2
✓ Branch 0 taken 1904821 times.
✓ Branch 1 taken 81059 times.
1985880 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iCompass
2319 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2320
2/4
✓ Branch 0 taken 1985880 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1985880 times.
1985880 if(itemid > -1 && checkbunny(itemid))
2321 1985880 tile+=itemsbuf[itemid].ltm;
2322 1985880 }
2323
2324
2/2
✓ Branch 0 taken 587437 times.
✓ Branch 1 taken 1482979 times.
2070416 if(current_item(itype_bosskey))
2325 {
2326 1482979 int32_t itemid =
2327
1/2
✓ Branch 0 taken 1482979 times.
✗ Branch 1 not taken.
1482979 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iBossKey
2329 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2330
2/4
✓ Branch 0 taken 1482979 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1482979 times.
1482979 if(itemid > -1 && checkbunny(itemid))
2331 1482979 tile+=itemsbuf[itemid].ltm;
2332 1482979 }
2333
2334
2/2
✓ Branch 0 taken 1988571 times.
✓ Branch 1 taken 81845 times.
2070416 if(current_item(itype_magiccontainer))
2335 {
2336 81845 int32_t itemid =
2337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81845 times.
81845 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iMagicC
2339 81845 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2340
2/4
✓ Branch 0 taken 81845 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81845 times.
81845 if(itemid > -1 && checkbunny(itemid))
2341 81845 tile+=itemsbuf[itemid].ltm;
2342 81845 }
2343
2344
2/2
✓ Branch 0 taken 275983 times.
✓ Branch 1 taken 1794433 times.
2070416 if(current_item(itype_triforcepiece))
2345 {
2346 1794433 int32_t itemid =
2347
1/2
✓ Branch 0 taken 1794433 times.
✗ Branch 1 not taken.
1794433 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2348 ? iTriforce
2349 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2350
2/4
✓ Branch 0 taken 1794433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1794433 times.
1794433 if(itemid > -1 && checkbunny(itemid))
2351 1794433 tile+=itemsbuf[itemid].ltm;
2352 1794433 }
2353
2354
2/2
✓ Branch 0 taken 2070416 times.
✓ Branch 1 taken 1060052992 times.
1062123408 for(int32_t i=0; i<itype_max; i++)
2355 {
2356
2/2
✓ Branch 0 taken 1010767872 times.
✓ Branch 1 taken 49285120 times.
1060052992 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2357 {
2358
2/2
✓ Branch 0 taken 962600 times.
✓ Branch 1 taken 48322520 times.
49285120 switch(i)
2359 {
2360 case itype_bomb:
2361 case itype_sbomb:
2362 case itype_clock:
2363 case itype_key:
2364 case itype_lkey:
2365 case itype_map:
2366 case itype_compass:
2367 case itype_bosskey:
2368 case itype_magiccontainer:
2369 case itype_triforcepiece:
2370 962600 continue; //already handled
2371 }
2372 48322520 }
2373 1059090392 int32_t itemid = current_item_id(i,false);
2374
2/2
✓ Branch 0 taken 1057019976 times.
✓ Branch 1 taken 2070416 times.
1059090392 if(i == itype_shield)
2375 2070416 itemid = getCurrentShield(false);
2376
2377
3/4
✓ Branch 0 taken 30047438 times.
✓ Branch 1 taken 1029042954 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30047438 times.
1059090392 if(itemid < 0 || !checkbunny(itemid))
2378 1029042954 continue;
2379
2380 30047438 itemdata const& itm = itemsbuf[itemid];
2381
2382
2/2
✓ Branch 0 taken 28058081 times.
✓ Branch 1 taken 1989357 times.
30047438 switch(itm.family)
2383 {
2384 case itype_shield:
2385
1/2
✓ Branch 0 taken 1989357 times.
✗ Branch 1 not taken.
1989357 if(itm.flags & ITEM_FLAG9) //active shield
2386 {
2387 if(!usingActiveShield(itemid))
2388 {
2389 tile+=itm.misc6; //'Inactive PTM'
2390 continue;
2391 }
2392 }
2393 1989357 break;
2394 }
2395
2396 30047438 tile+=itm.ltm;
2397 30047438 }
2398
2399 2070416 return tile;
2400 }
2401
2402 2070416 int32_t bunny_tile_mod()
2403 {
2404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2070416 times.
2070416 if(Hero.BunnyClock())
2405 {
2406 return game->get_bunny_ltm();
2407 }
2408 2070416 return 0;
2409 2070416 }
2410
2411 // Hints are drawn on a separate layer to combo reveals.
2412 1248 void draw_lens_under(BITMAP *dest, bool layer)
2413 {
2414 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2415 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2416 //Lens flag 3: Don't show armos/chest/dive items
2417 //Lens flag 4: Show Raft Paths
2418 //Lens flag 5: Show Invisible Enemies
2419
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 624 times.
✓ Branch 3 taken 624 times.
1248 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2420
2421 1248 int32_t strike_hint_table[11]=
2422 {
2423 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2424 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2425 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2426 };
2427
2428 // int32_t page = tmpscr->cpage;
2429 {
2430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
1248 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2431 // int32_t temptimer=0;
2432 1248 int32_t tempitem, tempweapon=0;
2433 1248 strike_hint=strike_hint_table[strike_hint_counter];
2434
2435
2/2
✓ Branch 0 taken 1211 times.
✓ Branch 1 taken 37 times.
1248 if(strike_hint_timer>32)
2436 {
2437 37 strike_hint_timer=0;
2438 37 strike_hint_counter=((strike_hint_counter+1)%11);
2439 37 }
2440
2441 1248 ++strike_hint_timer;
2442
2443
2/2
✓ Branch 0 taken 219648 times.
✓ Branch 1 taken 1248 times.
220896 for(int32_t i=0; i<176; i++)
2444 {
2445 219648 int32_t x = (i & 15) << 4;
2446 219648 int32_t y = (i & 0xF0) + playing_field_offset;
2447 219648 int32_t tempitemx=-16, tempitemy=-16;
2448 219648 int32_t tempweaponx=-16, tempweapony=-16;
2449
2450
2/2
✓ Branch 0 taken 439296 times.
✓ Branch 1 taken 219648 times.
658944 for(int32_t iter=0; iter<2; ++iter)
2451 {
2452 439296 int32_t checkflag=0;
2453
2454
2/2
✓ Branch 0 taken 219648 times.
✓ Branch 1 taken 219648 times.
439296 if(iter==0)
2455 {
2456 219648 checkflag=combobuf[tmpscr->data[i]].flag;
2457 219648 }
2458 else
2459 {
2460 219648 checkflag=tmpscr->sflag[i];
2461 }
2462
2463
1/2
✓ Branch 0 taken 439296 times.
✗ Branch 1 not taken.
439296 if(checkflag==mfSTRIKE)
2464 {
2465 if(!hints)
2466 {
2467 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2468 }
2469 else
2470 {
2471 checkflag = strike_hint;
2472 }
2473 }
2474
2475
6/36
✓ Branch 0 taken 422304 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 528 times.
✓ Branch 5 taken 16176 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 96 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
439296 switch(checkflag)
2476 {
2477 case 0:
2478 case mfZELDA:
2479 case mfPUSHED:
2480 case mfENEMY0:
2481 case mfENEMY1:
2482 case mfENEMY2:
2483 case mfENEMY3:
2484 case mfENEMY4:
2485 case mfENEMY5:
2486 case mfENEMY6:
2487 case mfENEMY7:
2488 case mfENEMY8:
2489 case mfENEMY9:
2490 case mfSINGLE:
2491 case mfSINGLE16:
2492 case mfNOENEMY:
2493 case mfTRAP_H:
2494 case mfTRAP_V:
2495 case mfTRAP_4:
2496 case mfTRAP_LR:
2497 case mfTRAP_UD:
2498 case mfNOGROUNDENEMY:
2499 case mfNOBLOCKS:
2500 case mfSCRIPT1:
2501 case mfSCRIPT2:
2502 case mfSCRIPT3:
2503 case mfSCRIPT4:
2504 case mfSCRIPT5:
2505 case mfSCRIPT6:
2506 case mfSCRIPT7:
2507 case mfSCRIPT8:
2508 case mfSCRIPT9:
2509 case mfSCRIPT10:
2510 case mfSCRIPT11:
2511 case mfSCRIPT12:
2512 case mfSCRIPT13:
2513 case mfSCRIPT14:
2514 case mfSCRIPT15:
2515 case mfSCRIPT16:
2516 case mfSCRIPT17:
2517 case mfSCRIPT18:
2518 case mfSCRIPT19:
2519 case mfSCRIPT20:
2520 case mfPITHOLE:
2521 case mfPITFALLFLOOR:
2522 case mfLAVA:
2523 case mfICE:
2524 case mfICEDAMAGE:
2525 case mfDAMAGE1:
2526 case mfDAMAGE2:
2527 case mfDAMAGE4:
2528 case mfDAMAGE8:
2529 case mfDAMAGE16:
2530 case mfDAMAGE32:
2531 case mfFREEZEALL:
2532 case mfFREZEALLANSFFCS:
2533 case mfFREEZEFFCSOLY:
2534 case mfSCRITPTW1TRIG:
2535 case mfSCRITPTW2TRIG:
2536 case mfSCRITPTW3TRIG:
2537 case mfSCRITPTW4TRIG:
2538 case mfSCRITPTW5TRIG:
2539 case mfSCRITPTW6TRIG:
2540 case mfSCRITPTW7TRIG:
2541 case mfSCRITPTW8TRIG:
2542 case mfSCRITPTW9TRIG:
2543 case mfSCRITPTW10TRIG:
2544 case mfTROWEL:
2545 case mfTROWELNEXT:
2546 case mfTROWELSPECIALITEM:
2547 case mfSLASHPOT:
2548 case mfLIFTPOT:
2549 case mfLIFTORSLASH:
2550 case mfLIFTROCK:
2551 case mfLIFTROCKHEAVY:
2552 case mfDROPITEM:
2553 case mfSPECIALITEM:
2554 case mfDROPKEY:
2555 case mfDROPLKEY:
2556 case mfDROPCOMPASS:
2557 case mfDROPMAP:
2558 case mfDROPBOSSKEY:
2559 case mfSPAWNNPC:
2560 case mfSWITCHHOOK:
2561 case mfSIDEVIEWLADDER:
2562 case mfSIDEVIEWPLATFORM:
2563 case mfNOENEMYSPAWN:
2564 case mfENEMYALL:
2565 case mfNOMIRROR:
2566 case mfUNSAFEGROUND:
2567 case mf168:
2568 case mf169:
2569 case mf170:
2570 case mf171:
2571 case mf172:
2572 case mf173:
2573 case mf174:
2574 case mf175:
2575 case mf176:
2576 case mf177:
2577 case mf178:
2578 case mf179:
2579 case mf180:
2580 case mf181:
2581 case mf182:
2582 case mf183:
2583 case mf184:
2584 case mf185:
2585 case mf186:
2586 case mf187:
2587 case mf188:
2588 case mf189:
2589 case mf190:
2590 case mf191:
2591 case mf192:
2592 case mf193:
2593 case mf194:
2594 case mf195:
2595 case mf196:
2596 case mf197:
2597 case mf198:
2598 case mf199:
2599 case mf200:
2600 case mf201:
2601 case mf202:
2602 case mf203:
2603 case mf204:
2604 case mf205:
2605 case mf206:
2606 case mf207:
2607 case mf208:
2608 case mf209:
2609 case mf210:
2610 case mf211:
2611 case mf212:
2612 case mf213:
2613 case mf214:
2614 case mf215:
2615 case mf216:
2616 case mf217:
2617 case mf218:
2618 case mf219:
2619 case mf220:
2620 case mf221:
2621 case mf222:
2622 case mf223:
2623 case mf224:
2624 case mf225:
2625 case mf226:
2626 case mf227:
2627 case mf228:
2628 case mf229:
2629 case mf230:
2630 case mf231:
2631 case mf232:
2632 case mf233:
2633 case mf234:
2634 case mf235:
2635 case mf236:
2636 case mf237:
2637 case mf238:
2638 case mf239:
2639 case mf240:
2640 case mf241:
2641 case mf242:
2642 case mf243:
2643 case mf244:
2644 case mf245:
2645 case mf246:
2646 case mf247:
2647 case mf248:
2648 case mf249:
2649 case mf250:
2650 case mf251:
2651 case mf252:
2652 case mf253:
2653 case mf254:
2654 case mfEXTENDED:
2655 422304 break;
2656
2657 case mfPUSHUD:
2658 case mfPUSHLR:
2659 case mfPUSH4:
2660 case mfPUSHU:
2661 case mfPUSHD:
2662 case mfPUSHL:
2663 case mfPUSHR:
2664 case mfPUSHUDNS:
2665 case mfPUSHLRNS:
2666 case mfPUSH4NS:
2667 case mfPUSHUNS:
2668 case mfPUSHDNS:
2669 case mfPUSHLNS:
2670 case mfPUSHRNS:
2671 case mfPUSHUDINS:
2672 case mfPUSHLRINS:
2673 case mfPUSH4INS:
2674 case mfPUSHUINS:
2675 case mfPUSHDINS:
2676 case mfPUSHLINS:
2677 case mfPUSHRINS:
2678
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
168 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2679
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2680 {
2681 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2682 }
2683
2684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 168 times.
168 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2685
3/6
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2686 {
2687
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 42 times.
84 if(hints)
2688 {
2689
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
42 switch(combobuf[tmpscr->data[i]].type)
2690 {
2691 case cPUSH_HEAVY:
2692 case cPUSH_HW:
2693 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2694 tempitemx=x, tempitemy=y;
2695
2696 if(tempitem>-1)
2697 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 break;
2700
2701 case cPUSH_HEAVY2:
2702 case cPUSH_HW2:
2703 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2704 42 tempitemx=x, tempitemy=y;
2705
2706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2707 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2708
2709 42 break;
2710 }
2711 42 }
2712 84 }
2713
2714 168 break;
2715
2716 case mfWHISTLE:
2717 if(hints)
2718 {
2719 tempitem=getItemID(itemsbuf,itype_whistle,1);
2720
2721 if(tempitem<0) break;
2722
2723 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2724 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2725 {
2726 tempitemx=x;
2727 tempitemy=y;
2728 }
2729
2730 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2731 }
2732
2733 break;
2734
2735 //Why is this here?
2736 case mfFAIRY:
2737 case mfMAGICFAIRY:
2738 case mfALLFAIRY:
2739 if(hints)
2740 {
2741 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2742
2743 if(tempitem < 0) break;
2744
2745 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2746 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2747 {
2748 tempitemx=x;
2749 tempitemy=y;
2750 }
2751
2752 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2753 }
2754
2755 break;
2756
2757 case mfBCANDLE:
2758 if(!hints)
2759 {
2760 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2761 }
2762 else
2763 {
2764 tempitem=getItemID(itemsbuf,itype_candle,1);
2765
2766 if(tempitem<0) break;
2767
2768 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2769 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2770 {
2771 tempitemx=x;
2772 tempitemy=y;
2773 }
2774
2775 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2776 }
2777
2778 break;
2779
2780 case mfRCANDLE:
2781 if(!hints)
2782 {
2783 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2784 }
2785 else
2786 {
2787 tempitem=getItemID(itemsbuf,itype_candle,2);
2788
2789 if(tempitem<0) break;
2790
2791 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794 tempitemx=x;
2795 tempitemy=y;
2796 }
2797
2798 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2799 }
2800
2801 break;
2802
2803 case mfWANDFIRE:
2804 if(!hints)
2805 {
2806 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2807 }
2808 else
2809 {
2810 tempitem=getItemID(itemsbuf,itype_wand,1);
2811
2812 if(tempitem<0) break;
2813
2814 tempweapon=wFire;
2815
2816 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2817 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2818 {
2819 tempitemx=x;
2820 tempitemy=y;
2821 }
2822 else
2823 {
2824 tempweaponx=x;
2825 tempweapony=y;
2826 }
2827
2828 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfDINSFIRE:
2835 if(!hints)
2836 {
2837 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2838 }
2839 else
2840 {
2841 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2842
2843 if(tempitem<0) break;
2844
2845 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 tempitemx=x;
2849 tempitemy=y;
2850 }
2851
2852 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 break;
2856
2857 case mfARROW:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_arrow,1);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfSARROW:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_arrow,2);
2888
2889 if(tempitem<0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfGARROW:
2904 if(!hints)
2905 {
2906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2907 }
2908 else
2909 {
2910 tempitem=getItemID(itemsbuf,itype_arrow,3);
2911
2912 if(tempitem<0) break;
2913
2914 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 tempitemx=x;
2918 tempitemy=y;
2919 }
2920
2921 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 break;
2925
2926 case mfBOMB:
2927 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2930 }
2931 else
2932 {
2933 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2934 tempweapon = wLitBomb;
2935
2936 //if (tempitem<0) break;
2937 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 tempweaponx=x;
2941 tempweapony=y;
2942 }
2943
2944 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 }
2946
2947 break;
2948
2949 case mfSBOMB:
2950
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2951 {
2952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2953 48 }
2954 else
2955 {
2956 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2957 //if (tempitem<0) break;
2958 48 tempweapon = wLitSBomb;
2959
2960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2961
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2962 {
2963 24 tempweaponx=x;
2964 24 tempweapony=y;
2965 24 }
2966
2967 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 }
2969
2970 96 break;
2971
2972 case mfARMOS_SECRET:
2973 if(!hints)
2974 {
2975 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2976 }
2977 break;
2978
2979 case mfBRANG:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2983 }
2984 else
2985 {
2986 tempitem=getItemID(itemsbuf,itype_brang,1);
2987
2988 if(tempitem<0) break;
2989
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempitemx=x;
2994 tempitemy=y;
2995 }
2996
2997 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 break;
3001
3002 case mfMBRANG:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3006 }
3007 else
3008 {
3009 tempitem=getItemID(itemsbuf,itype_brang,2);
3010
3011 if(tempitem<0) break;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempitemx=x;
3017 tempitemy=y;
3018 }
3019
3020 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3021 }
3022
3023 break;
3024
3025 case mfFBRANG:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3029 }
3030 else
3031 {
3032 tempitem=getItemID(itemsbuf,itype_brang,3);
3033
3034 if(tempitem<0) break;
3035
3036 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 tempitemx=x;
3040 tempitemy=y;
3041 }
3042
3043 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3044 }
3045
3046 break;
3047
3048 case mfWANDMAGIC:
3049 if(!hints)
3050 {
3051 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3052 }
3053 else
3054 {
3055 tempitem=getItemID(itemsbuf,itype_wand,1);
3056
3057 if(tempitem<0) break;
3058
3059 tempweapon=itemsbuf[tempitem].wpn3;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067 else
3068 {
3069 tempweaponx=x;
3070 tempweapony=y;
3071 --lens_hint_weapon[wMagic][4];
3072
3073 if(lens_hint_weapon[wMagic][4]<-8)
3074 {
3075 lens_hint_weapon[wMagic][4]=8;
3076 }
3077 }
3078
3079 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3080 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 }
3082
3083 break;
3084
3085 case mfREFMAGIC:
3086 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3089 }
3090 else
3091 {
3092 tempitem=getItemID(itemsbuf,itype_shield,3);
3093
3094 if(tempitem<0) break;
3095
3096 tempweapon=ewMagic;
3097
3098 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 tempitemx=x;
3102 tempitemy=y;
3103 }
3104 else
3105 {
3106 tempweaponx=x;
3107 tempweapony=y;
3108
3109 if(lens_hint_weapon[ewMagic][2]==up)
3110 {
3111 --lens_hint_weapon[ewMagic][4];
3112 }
3113 else
3114 {
3115 ++lens_hint_weapon[ewMagic][4];
3116 }
3117
3118 if(lens_hint_weapon[ewMagic][4]>8)
3119 {
3120 lens_hint_weapon[ewMagic][2]=up;
3121 }
3122
3123 if(lens_hint_weapon[ewMagic][4]<=0)
3124 {
3125 lens_hint_weapon[ewMagic][2]=down;
3126 }
3127 }
3128
3129 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3130 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3131 }
3132
3133 break;
3134
3135 case mfREFFIREBALL:
3136 if(!hints)
3137 {
3138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3139 }
3140 else
3141 {
3142 tempitem=getItemID(itemsbuf,itype_shield,3);
3143
3144 if(tempitem<0) break;
3145
3146 tempweapon=ewFireball;
3147
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3149 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3150 {
3151 tempitemx=x;
3152 tempitemy=y;
3153 tempweaponx=x;
3154 tempweapony=y;
3155 ++lens_hint_weapon[ewFireball][3];
3156
3157 if(lens_hint_weapon[ewFireball][3]>8)
3158 {
3159 lens_hint_weapon[ewFireball][3]=-8;
3160 lens_hint_weapon[ewFireball][4]=8;
3161 }
3162
3163 if(lens_hint_weapon[ewFireball][3]>0)
3164 {
3165 ++lens_hint_weapon[ewFireball][4];
3166 }
3167 else
3168 {
3169 --lens_hint_weapon[ewFireball][4];
3170 }
3171 }
3172
3173 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3174 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3175 }
3176
3177 break;
3178
3179 case mfSWORD:
3180 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3183 }
3184 else
3185 {
3186 tempitem=getItemID(itemsbuf,itype_sword,1);
3187
3188 if(tempitem<0) break;
3189
3190 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 tempitemx=x;
3194 tempitemy=y;
3195 }
3196
3197 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3198 }
3199
3200 break;
3201
3202 case mfWSWORD:
3203 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3206 }
3207 else
3208 {
3209 tempitem=getItemID(itemsbuf,itype_sword,2);
3210
3211 if(tempitem<0) break;
3212
3213 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3214 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3215 {
3216 tempitemx=x;
3217 tempitemy=y;
3218 }
3219
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfMSWORD:
3226 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3229 }
3230 else
3231 {
3232 tempitem=getItemID(itemsbuf,itype_sword,3);
3233
3234 if(tempitem<0) break;
3235
3236 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 tempitemx=x;
3240 tempitemy=y;
3241 }
3242
3243 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 }
3245
3246 break;
3247
3248 case mfXSWORD:
3249 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3252 }
3253 else
3254 {
3255 tempitem=getItemID(itemsbuf,itype_sword,4);
3256
3257 if(tempitem<0) break;
3258
3259 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3260 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3261 {
3262 tempitemx=x;
3263 tempitemy=y;
3264 }
3265
3266 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3267 }
3268
3269 break;
3270
3271 case mfSWORDBEAM:
3272 if(!hints)
3273 {
3274 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3275 }
3276 else
3277 {
3278 tempitem=getItemID(itemsbuf,itype_sword,1);
3279
3280 if(tempitem<0) break;
3281
3282 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3283 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3284 {
3285 tempitemx=x;
3286 tempitemy=y;
3287 }
3288
3289 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3290 }
3291
3292 break;
3293
3294 case mfWSWORDBEAM:
3295 if(!hints)
3296 {
3297 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3298 }
3299 else
3300 {
3301 tempitem=getItemID(itemsbuf,itype_sword,2);
3302
3303 if(tempitem<0) break;
3304
3305 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3306 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3307 {
3308 tempitemx=x;
3309 tempitemy=y;
3310 }
3311
3312 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3313 }
3314
3315 break;
3316
3317 case mfMSWORDBEAM:
3318 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3321 }
3322 else
3323 {
3324 tempitem=getItemID(itemsbuf,itype_sword,3);
3325
3326 if(tempitem<0) break;
3327
3328 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 tempitemx=x;
3332 tempitemy=y;
3333 }
3334
3335 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3336 }
3337
3338 break;
3339
3340 case mfXSWORDBEAM:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,4);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3359 }
3360
3361 break;
3362
3363 case mfHOOKSHOT:
3364 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3367 }
3368 else
3369 {
3370 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3371
3372 if(tempitem<0) break;
3373
3374 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 tempitemx=x;
3378 tempitemy=y;
3379 }
3380
3381 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 break;
3385
3386 case mfWAND:
3387 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3390 }
3391 else
3392 {
3393 tempitem=getItemID(itemsbuf,itype_wand,1);
3394
3395 if(tempitem<0) break;
3396
3397 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 tempitemx=x;
3401 tempitemy=y;
3402 }
3403
3404 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 break;
3408
3409 case mfHAMMER:
3410 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3413 }
3414 else
3415 {
3416 tempitem=getItemID(itemsbuf,itype_hammer,1);
3417
3418 if(tempitem<0) break;
3419
3420 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 tempitemx=x;
3424 tempitemy=y;
3425 }
3426
3427 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3428 }
3429
3430 break;
3431
3432 case mfARMOS_ITEM:
3433 case mfDIVE_ITEM:
3434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3435 {
3436 528 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3437 528 }
3438 528 break;
3439
3440 case 16:
3441 case 17:
3442 case 18:
3443 case 19:
3444 case 20:
3445 case 21:
3446 case 22:
3447 case 23:
3448 case 24:
3449 case 25:
3450 case 26:
3451 case 27:
3452 case 28:
3453 case 29:
3454 case 30:
3455 case 31:
3456
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
24 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3458 12 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3459
3460 24 break;
3461 case mfSECRETSNEXT:
3462 if(!hints)
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3464 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3465
3466 break;
3467
3468 case mfSTRIKE:
3469 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3470 {
3471 goto special;
3472 }
3473 else
3474 {
3475 break;
3476 }
3477
3478 16176 default: goto special;
3479
3480 special:
3481
7/8
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 8088 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 7980 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8004 times.
16176 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3482 {
3483
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 42 rectfill(dest,x,y,x+15,y+15,WHITE);
3486 42 }
3487 84 }
3488
3489 16176 break;
3490 }
3491 439296 }
3492 219648 }
3493
3494
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 624 times.
1248 if(layer)
3495 {
3496
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[0]==dWALK)
3497 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3498
3499
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[1]==dWALK)
3500 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3501
3502
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[2]==dWALK)
3503 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3504
3505
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[3]==dWALK)
3506 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3507
3508
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[0]==dBOMB)
3509 {
3510 showbombeddoor(dest, 0);
3511 }
3512
3513
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[1]==dBOMB)
3514 {
3515 showbombeddoor(dest, 1);
3516 }
3517
3518
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[2]==dBOMB)
3519 {
3520 showbombeddoor(dest, 2);
3521 }
3522
3523
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[3]==dBOMB)
3524 {
3525 showbombeddoor(dest, 3);
3526 }
3527 624 }
3528
3529
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 48 times.
1248 if(tmpscr->stairx + tmpscr->stairy)
3530 {
3531
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if(!hints)
3532 {
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 24 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3535 24 }
3536 else
3537 {
3538
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tmpscr->flags&fWHISTLE)
3539 {
3540 tempitem=getItemID(itemsbuf,itype_whistle,1);
3541 int32_t tempitemx=-16;
3542 int32_t tempitemy=-16;
3543
3544 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3545 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3546 {
3547 tempitemx=tmpscr->stairx;
3548 tempitemy=tmpscr->stairy+playing_field_offset;
3549 }
3550
3551 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 }
3553 }
3554 48 }
3555 }
3556 1248 }
3557
3558 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3559
3560 624 void draw_lens_over()
3561 {
3562 // Oh, what the heck.
3563 static BITMAP *lens_scr = NULL;
3564 static int32_t last_width = -1;
3565 624 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3566
3567 // Only redraw the circle if the size has changed
3568
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 1 times.
624 if(width != last_width)
3569 {
3570
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(lens_scr == NULL)
3571 {
3572 1 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3573 1 }
3574
3575 1 clear_to_color(lens_scr, BLACK);
3576 1 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3577 1 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3578 1 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3579 1 last_width=width;
3580 1 }
3581
3582 624 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3583 624 }
3584
3585 //----------------------------------------------------------------
3586
3587 7245 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3588 {
3589 //recreating a big bitmap every frame is highly sluggish.
3590
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7244 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
7245 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3591 7245 clear_to_color(wavebuf, BLACK);
3592 7245 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3593
3594 int32_t ofs;
3595 // int32_t amplitude=8;
3596 // int32_t wavelength=4;
3597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7245 times.
7245 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3598
2/6
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7245 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3599 7245 int32_t amp2=168;
3600
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
7245 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3601 7245 int32_t i=frame%amp2;
3602
3603
2/2
✓ Branch 0 taken 1217160 times.
✓ Branch 1 taken 7245 times.
1224405 for(int32_t j=0; j<168; j++)
3604 {
3605
3/4
✓ Branch 0 taken 608580 times.
✓ Branch 1 taken 608580 times.
✓ Branch 2 taken 608580 times.
✗ Branch 3 not taken.
1217160 if(j&1 && interpol)
3606 {
3607 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3608 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3609 }
3610 else
3611 {
3612 1217160 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3613 }
3614
3615
1/2
✓ Branch 0 taken 1217160 times.
✗ Branch 1 not taken.
1217160 if(ofs)
3616 {
3617
2/2
✓ Branch 0 taken 311592960 times.
✓ Branch 1 taken 1217160 times.
312810120 for(int32_t k=0; k<256; k++)
3618 {
3619 311592960 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3620 311592960 }
3621 1217160 }
3622 1217160 }
3623 7245 }
3624
3625 384 void draw_fuzzy(int32_t fuzz)
3626 // draws from right half of scrollbuf to framebuf
3627 {
3628 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3629 byte *start, *si, *di;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(fuzz<1)
3632 fuzz = 1;
3633
3634 384 xstep = 128%fuzz;
3635
3636
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 304 times.
384 if(xstep > 0)
3637 304 xstep = fuzz-xstep;
3638
3639 384 ystep = 112%fuzz;
3640
3641
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 272 times.
384 if(ystep > 0)
3642 272 ystep = fuzz-ystep;
3643
3644 384 firsty = 1;
3645
3646
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 13856 times.
14240 for(y=0; y<224;)
3647 {
3648 13856 start = &(scrollbuf->line[y][256]);
3649
3650
4/4
✓ Branch 0 taken 13664 times.
✓ Branch 1 taken 86208 times.
✓ Branch 2 taken 86016 times.
✓ Branch 3 taken 13856 times.
99872 for(dy=0; dy<ystep && dy+y<224; dy++)
3651 {
3652 86016 si = start;
3653 86016 di = &(framebuf->line[y+dy][0]);
3654 86016 i = xstep;
3655 86016 firstx = 1;
3656
3657
2/2
✓ Branch 0 taken 22020096 times.
✓ Branch 1 taken 86016 times.
22106112 for(dx=0; dx<256; dx++)
3658 {
3659 22020096 *(di++) = *si;
3660
3661
2/2
✓ Branch 0 taken 18554368 times.
✓ Branch 1 taken 3465728 times.
22020096 if(++i >= fuzz)
3662 {
3663
2/2
✓ Branch 0 taken 3379712 times.
✓ Branch 1 taken 86016 times.
3465728 if(!firstx)
3664 3379712 si += fuzz;
3665 else
3666 {
3667 86016 si += fuzz-xstep;
3668 86016 firstx = 0;
3669 }
3670
3671 3465728 i = 0;
3672 3465728 }
3673 22020096 }
3674 86016 }
3675
3676
2/2
✓ Branch 0 taken 13472 times.
✓ Branch 1 taken 384 times.
13856 if(!firsty)
3677 13472 y += fuzz;
3678 else
3679 {
3680 384 y += ystep;
3681 384 ystep = fuzz;
3682 384 firsty = 0;
3683 }
3684 }
3685 384 }
3686
3687 3536180 void updatescr(bool allowwavy)
3688 {
3689
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3536166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
3536180 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3690
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3536166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
3536180 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3691
3692
1/2
✓ Branch 0 taken 3536180 times.
✗ Branch 1 not taken.
3536180 if(toogam)
3693 {
3694 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3695 }
3696
3697
1/2
✓ Branch 0 taken 3536180 times.
✗ Branch 1 not taken.
3536180 if(Showpal)
3698 dump_pal(framebuf);
3699
3700
2/2
✓ Branch 0 taken 3508891 times.
✓ Branch 1 taken 27289 times.
3536180 if(!Playing)
3701 27289 black_opening_count=0;
3702
3703
2/2
✓ Branch 0 taken 3519350 times.
✓ Branch 1 taken 16830 times.
3536180 if(black_opening_count<0) //shape is opening up
3704 {
3705 16830 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3706
3707
2/4
✓ Branch 0 taken 16830 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16830 times.
16830 if(Advance||(!Paused))
3708 {
3709 16830 ++black_opening_count;
3710 16830 }
3711 16830 }
3712
2/2
✓ Branch 0 taken 3511694 times.
✓ Branch 1 taken 7656 times.
3519350 else if(black_opening_count>0) //shape is closing
3713 {
3714 7656 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3715
3716
2/4
✓ Branch 0 taken 7656 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7656 times.
7656 if(Advance||(!Paused))
3717 {
3718 7656 --black_opening_count;
3719 7656 }
3720 7656 }
3721
3722
3/4
✓ Branch 0 taken 3512065 times.
✓ Branch 1 taken 24115 times.
✓ Branch 2 taken 3512065 times.
✗ Branch 3 not taken.
3536180 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3723 {
3724 black_opening_shape = bosCIRCLE;
3725 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3726 refreshTints();
3727 refreshpal=true;
3728 }
3729
3730
2/2
✓ Branch 0 taken 3434000 times.
✓ Branch 1 taken 102180 times.
3536180 if(refreshpal)
3731 {
3732 102180 refreshpal=false;
3733 102180 RAMpal[253] = _RGB(0,0,0);
3734 102180 RAMpal[254] = _RGB(63,63,63);
3735 102180 hw_palette = &RAMpal;
3736 102180 update_hw_pal = true;
3737
3738 102180 create_rgb_table(&rgb_table, RAMpal, NULL);
3739 102180 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3740 102180 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3741
3742
2/2
✓ Branch 0 taken 26158080 times.
✓ Branch 1 taken 102180 times.
26260260 for(int32_t q=0; q<PAL_SIZE; q++)
3743 {
3744 26158080 trans_table2.data[0][q] = q;
3745 26158080 trans_table2.data[q][q] = q;
3746 26158080 }
3747 102180 }
3748
3749 3536180 bool clearwavy = (wavy <= 0);
3750
3751
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 3528935 times.
3536180 if(wavy <= 0)
3752 {
3753 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3754 3528935 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3755 3528935 }
3756
3757 3536180 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3758
3759
4/6
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 3528935 times.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7245 times.
3536180 if(wavy && Playing && allowwavy)
3760 {
3761 7245 draw_wavy(framebuf, wavybuf, wavy,false);
3762 7245 }
3763
3764
2/2
✓ Branch 0 taken 3528935 times.
✓ Branch 1 taken 7245 times.
3536180 if(clearwavy)
3765 3528935 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3766
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3767 7245 wavy--; // Wavy was set by a script. Decrement it.
3768
3769
5/6
✓ Branch 0 taken 3508891 times.
✓ Branch 1 taken 27289 times.
✓ Branch 2 taken 60442 times.
✓ Branch 3 taken 3448449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60442 times.
3536180 if(Playing && msgpos && !screenscrolling)
3770 {
3771
1/2
✓ Branch 0 taken 60442 times.
✗ Branch 1 not taken.
60442 if(!(msg_bg_display_buf->clip))
3772 60442 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3773
1/2
✓ Branch 0 taken 60442 times.
✗ Branch 1 not taken.
60442 if(!(msg_portrait_display_buf->clip))
3774 60442 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3775
1/2
✓ Branch 0 taken 60442 times.
✗ Branch 1 not taken.
60442 if(!(msg_txt_display_buf->clip))
3776 60442 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3777 60442 }
3778
3779 /*
3780 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3781 {
3782 BITMAP* subBmp = 0;
3783 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3784 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3785 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3786 destroy_bitmap(subBmp);
3787 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3788 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3789 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3790 }
3791 */
3792
3793
2/2
✓ Branch 0 taken 3525891 times.
✓ Branch 1 taken 10289 times.
3536180 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3794
3795
2/2
✓ Branch 0 taken 3525891 times.
✓ Branch 1 taken 10289 times.
3536180 if(nosubscr)
3796 {
3797 10289 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3798 10289 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3799 10289 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3800 10289 }
3801
3802 //TODO: Optimize blit 'overcalls' -Gleeok
3803
2/2
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 3525891 times.
3536180 BITMAP *source = nosubscr ? panorama : wavybuf;
3804 3536180 blit(source,framebuf,0,0,0,0,256,224);
3805
3806 3536180 update_hw_screen();
3807 3536180 }
3808
3809 //----------------------------------------------------------------
3810
3811 PALETTE sys_pal;
3812
3813 int32_t onGUISnapshot()
3814 {
3815 char buf[200];
3816 int32_t num=0;
3817 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3818 do
3819 {
3820 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3821 }
3822 while(num<99999 && exists(buf));
3823
3824 BITMAP *b = create_bitmap_ex(8,resx,resy);
3825
3826 if(b)
3827 {
3828 if(MenuOpen)
3829 {
3830 //Cannot load game's palette while GUI elements are in focus. -Z
3831 //If there is a way to do this, then I have missed it.
3832 /*
3833 game_pal();
3834 RAMpal[253] = _RGB(0,0,0);
3835 RAMpal[254] = _RGB(63,63,63);
3836 set_palette_range(RAMpal,0,255,false);
3837 memcpy(RAMpal, snappal, sizeof(snappal));
3838 create_rgb_table(&rgb_table, RAMpal, NULL);
3839 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3840 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3841
3842 for(int32_t q=0; q<PAL_SIZE; q++)
3843 {
3844 trans_table2.data[0][q] = q;
3845 trans_table2.data[q][q] = q;
3846 }
3847 */
3848 //ringcolor(false);
3849 //get_palette(RAMpal);
3850 blit(screen,b,0,0,0,0,resx,resy);
3851 //al_trace("Menu Open\n");
3852 //game_pal();
3853 //PALETTE temppal;
3854 //get_palette(temppal);
3855 //system_pal();
3856 save_bitmap(buf,b,sys_pal);
3857 //save_bitmap(buf,b,RAMpal);
3858 //save_bitmap(buf,b,snappal);
3859 }
3860 else
3861 {
3862 blit(screen,b,0,0,0,0,resx,resy);
3863 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3864 }
3865 destroy_bitmap(b);
3866 }
3867
3868 return D_O_K;
3869 }
3870
3871 int32_t onNonGUISnapshot()
3872 {
3873 PALETTE temppal;
3874 get_palette(temppal);
3875 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3876
3877 char buf[200];
3878 int32_t num=0;
3879
3880 do
3881 {
3882 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3883 }
3884 while(num<99999 && exists(buf));
3885
3886 BITMAP *panorama = create_bitmap_ex(8,256,168);
3887 /*
3888 PALETTE tempRAMpal;
3889 get_palette(tempRAMpal);
3890
3891 if(tmpscr->flags3&fNOSUBSCR)
3892 {
3893 clear_to_color(panorama,0);
3894 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3895 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3896 }
3897 else
3898 {
3899 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3900 }
3901
3902 destroy_bitmap(panorama);
3903 return D_O_K;
3904 */
3905 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3906 {
3907 clear_to_color(panorama,0);
3908 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3909 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3910 }
3911 else
3912 {
3913 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3914 }
3915
3916 destroy_bitmap(panorama);
3917 return D_O_K;
3918 }
3919
3920 int32_t onSnapshot()
3921 {
3922 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3923 {
3924 onGUISnapshot();
3925 }
3926 else
3927 {
3928 onNonGUISnapshot();
3929 }
3930
3931 return D_O_K;
3932 }
3933
3934 int32_t onSaveMapPic()
3935 {
3936 int32_t mapres2 = 0;
3937 char buf[200];
3938 int32_t num=0;
3939 mapscr tmpscr_b[2];
3940 mapscr tmpscr_c[6];
3941 BITMAP* _screen_draw_buffer = NULL;
3942 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3943 set_clip_state(_screen_draw_buffer,1);
3944
3945 for(int32_t i=0; i<6; ++i)
3946 {
3947 tmpscr_c[i] = tmpscr2[i];
3948 tmpscr2[i].zero_memory();
3949
3950 if(i>=2)
3951 {
3952 continue;
3953 }
3954
3955 tmpscr_b[i] = tmpscr[i];
3956 tmpscr[i].zero_memory();
3957 }
3958
3959 do
3960 {
3961 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3962 }
3963 while(num<99999 && exists(buf));
3964
3965 BITMAP* mappic = NULL;
3966
3967
3968 bool done=false, redraw=true;
3969
3970 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3971
3972 if(!mappic)
3973 {
3974 system_pal();
3975 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3976 game_pal();
3977 return D_O_K;;
3978 }
3979
3980 // draw the map
3981 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3982
3983 for(int32_t y=0; y<8; y++)
3984 {
3985 for(int32_t x=0; x<16; x++)
3986 {
3987 if(!displayOnMap(x, y))
3988 {
3989 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3990 }
3991 else
3992 {
3993 int32_t s = (y<<4) + x;
3994 loadscr2(1,s,-1);
3995
3996 for(int32_t i=0; i<6; i++)
3997 {
3998 if(tmpscr[1].layermap[i]<=0)
3999 continue;
4000
4001 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4002 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4003 {
4004 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4005
4006 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4007 }
4008 }
4009
4010 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4011
4012 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4013
4014 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4015 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4016
4017 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4018
4019 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4020 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4021 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4022 {
4023 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4024 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4025 }
4026 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4027
4028 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4029
4030 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4031 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4032 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4033 {
4034 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4035 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4036 }
4037 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4038 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4039
4040 }
4041
4042 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4043 }
4044 }
4045
4046 for(int32_t i=0; i<6; ++i)
4047 {
4048 tmpscr2[i]=tmpscr_c[i];
4049
4050 if(i>=2)
4051 {
4052 continue;
4053 }
4054
4055 tmpscr[i]=tmpscr_b[i];
4056 }
4057
4058 save_bitmap(buf,mappic,RAMpal);
4059 destroy_bitmap(mappic);
4060 destroy_bitmap(_screen_draw_buffer);
4061 return D_O_K;
4062 }
4063
4064 /*
4065 int32_t onSaveMapPic()
4066 {
4067 BITMAP* mappic = NULL;
4068 BITMAP* _screen_draw_buffer = NULL;
4069 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4070 int32_t mapres2 = 0;
4071 char buf[20];
4072 int32_t num=0;
4073 set_clip_state(_screen_draw_buffer,1);
4074 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4075
4076 do
4077 {
4078 sprintf(buf, "zelda%03d.png", ++num);
4079 }
4080 while(num<999 && exists(buf));
4081
4082 // if(!mappic) {
4083 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4084
4085 if(!mappic)
4086 {
4087 system_pal();
4088 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4089 game_pal();
4090 return D_O_K;
4091 }
4092
4093 // }
4094
4095 int32_t layermap, layerscreen;
4096 int32_t x2=0;
4097
4098 // draw the map
4099 for(int32_t y=0; y<8; y++)
4100 {
4101 for(int32_t x=0; x<16; x++)
4102 {
4103 int32_t s = (y<<4) + x;
4104
4105 if(!displayOnMap(x, y))
4106 {
4107 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4108 }
4109 else
4110 {
4111 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4112 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4113
4114 for(int32_t k=0; k<4; k++)
4115 {
4116 if(k==2)
4117 {
4118 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4119 }
4120
4121 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4122
4123 if(layermap>-1)
4124 {
4125 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4126
4127 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4128 {
4129 for(int32_t i=0; i<176; i++)
4130 {
4131 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4132 }
4133 }
4134 else
4135 {
4136 for(int32_t i=0; i<176; i++)
4137 {
4138 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4139 }
4140 }
4141 }
4142 }
4143
4144 for(int32_t i=0; i<176; i++)
4145 {
4146 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4147 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4148 {
4149 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4150 }
4151 }
4152
4153 for(int32_t k=4; k<6; k++)
4154 {
4155 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4156
4157 if(layermap>-1)
4158 {
4159 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4160
4161 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4162 {
4163 for(int32_t i=0; i<176; i++)
4164 {
4165 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4166 }
4167 }
4168 else
4169 {
4170 for(int32_t i=0; i<176; i++)
4171 {
4172 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4173 }
4174 }
4175 }
4176 }
4177 }
4178
4179 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4180 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4181 }
4182
4183 }
4184
4185 save_bitmap(buf,mappic,RAMpal);
4186 destroy_bitmap(mappic);
4187 destroy_bitmap(_screen_draw_buffer);
4188 return D_O_K;
4189 }
4190 */
4191
4192 14 void f_Quit(int32_t type)
4193 {
4194
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4195 return;
4196
4197 14 bool from_menu = is_sys_pal;
4198
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4200 {
4201 14 music_pause();
4202 14 pause_all_sfx();
4203 14 }
4204 14 enter_sys_pal();
4205 14 clear_keybuf();
4206
4207 14 replay_poll();
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4209 14 replay_peek_quit();
4210
4211
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4212 switch(type)
4213 {
4214 case qQUIT:
4215 onQuit();
4216 break;
4217
4218 case qRESET:
4219 onReset();
4220 break;
4221
4222 case qEXIT:
4223 onExit();
4224 break;
4225 }
4226
4227
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4228 {
4229 14 kill_sfx();
4230 14 music_stop();
4231 14 exit_sys_pal();
4232 14 update_hw_screen();
4233 14 }
4234 else
4235 {
4236 exit_sys_pal();
4237 if(!from_menu)
4238 {
4239 music_resume();
4240 resume_all_sfx();
4241 }
4242 }
4243
4244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4245 14 show_mouse(NULL);
4246 14 eat_buttons();
4247
4248 14 zc_readrawkey(KEY_ESC);
4249
4250 14 zc_readrawkey(KEY_ENTER);
4251 14 }
4252
4253 //----------------------------------------------------------------
4254
4255 int32_t onNoWalls()
4256 {
4257 cheats_enqueue(Cheat::Walls);
4258 return D_O_K;
4259 }
4260
4261 int32_t onIgnoreSideview()
4262 {
4263 cheats_enqueue(Cheat::IgnoreSideView);
4264 return D_O_K;
4265 }
4266
4267 3587339 int32_t input_idle(bool checkmouse)
4268 {
4269 static int32_t mx, my, mz, mb;
4270
4271
4/6
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699241 times.
✓ Branch 3 taken 2888098 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 699241 times.
4286580 if(keypressed() || zc_key_pressed() ||
4272
4/8
✓ Branch 0 taken 699241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699241 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 699241 times.
✗ Branch 7 not taken.
699241 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4273 {
4274 2888098 idle_count = 0;
4275
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2888098 times.
2888098 if(active_count < MAX_ACTIVE)
4277 {
4278 2888098 ++active_count;
4279 2888098 }
4280 2888098 }
4281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 699241 times.
699241 else if(idle_count < MAX_IDLE)
4282 {
4283 699241 ++idle_count;
4284 699241 active_count = 0;
4285 699241 }
4286
4287 3587339 mx = mouse_x;
4288 3587339 my = mouse_y;
4289 3587339 mz = mouse_z;
4290 3587339 mb = mouse_b;
4291
4292 3587339 return idle_count;
4293 }
4294
4295 int32_t onGoFast()
4296 {
4297 cheats_enqueue(Cheat::Fast);
4298 return D_O_K;
4299 }
4300
4301 int32_t onKillCheat()
4302 {
4303 cheats_enqueue(Cheat::Kill);
4304 return D_O_K;
4305 }
4306
4307 int32_t onShowLayer0()
4308 {
4309 show_layer_0 = !show_layer_0;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayer1()
4313 {
4314 show_layer_1 = !show_layer_1;
4315 return D_O_K;
4316 }
4317 int32_t onShowLayer2()
4318 {
4319 show_layer_2 = !show_layer_2;
4320 return D_O_K;
4321 }
4322 int32_t onShowLayer3()
4323 {
4324 show_layer_3 = !show_layer_3;
4325 return D_O_K;
4326 }
4327 int32_t onShowLayer4()
4328 {
4329 show_layer_4 = !show_layer_4;
4330 return D_O_K;
4331 }
4332 int32_t onShowLayer5()
4333 {
4334 show_layer_5 = !show_layer_5;
4335 return D_O_K;
4336 }
4337 int32_t onShowLayer6()
4338 {
4339 show_layer_6 = !show_layer_6;
4340 return D_O_K;
4341 }
4342 int32_t onShowLayerO()
4343 {
4344 show_layer_over=!show_layer_over;
4345 return D_O_K;
4346 }
4347 int32_t onShowLayerP()
4348 {
4349 show_layer_push=!show_layer_push;
4350 return D_O_K;
4351 }
4352 int32_t onShowLayerS()
4353 {
4354 show_sprites=!show_sprites;
4355 return D_O_K;
4356 }
4357 int32_t onShowLayerF()
4358 {
4359 show_ffcs=!show_ffcs;
4360 return D_O_K;
4361 }
4362 int32_t onShowLayerW()
4363 {
4364 show_walkflags=!show_walkflags;
4365 return D_O_K;
4366 }
4367 int32_t onShowLayerE()
4368 {
4369 show_effectflags=!show_effectflags;
4370 return D_O_K;
4371 }
4372 int32_t onShowFFScripts()
4373 {
4374 show_ff_scripts=!show_ff_scripts;
4375 return D_O_K;
4376 }
4377 int32_t onShowHitboxes()
4378 {
4379 show_hitboxes=!show_hitboxes;
4380 return D_O_K;
4381 }
4382
4383 int32_t onLightSwitch()
4384 {
4385 cheats_enqueue(Cheat::Light);
4386 return D_O_K;
4387 }
4388
4389 int32_t onGoTo();
4390 int32_t onGoToComplete();
4391
4392 3587339 void syskeys()
4393 {
4394 3587339 update_system_keys();
4395
4396 int32_t oldtitle_version;
4397
4398
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(close_button_quit)
4399 {
4400 close_button_quit=false;
4401 f_Quit(qEXIT);
4402 }
4403
4404 3587339 poll_joystick();
4405
4406
2/10
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3587339 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3587339 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4407 {
4408 oldtitle_version=title_version;
4409 System();
4410 }
4411
4412 3587339 mouse_down=gui_mouse_b();
4413
4414
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(zc_read_system_key(KEY_F1))
4415 {
4416 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4417 {
4418 halt=!halt;
4419 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4420 }
4421 else
4422 {
4423 Throttlefps=!Throttlefps;
4424 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4425 logic_counter=0;
4426 }
4427 }
4428
4429 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4430 /*
4431 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4432 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4433 */
4434
4435
1/4
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3587339 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4436
4437
1/4
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3587339 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4438
4439
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(zc_read_system_key(KEY_F2))
4440 {
4441 ShowFPS=!ShowFPS;
4442 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4443 }
4444
4445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3587339 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4446
4447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3587339 if(zc_read_system_key(KEY_F4) && Playing)
4448 {
4449 Paused=true;
4450 Advance=true;
4451 }
4452
4453
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(zc_read_system_key(KEY_F6)) onTryQuit();
4454
4455 #ifndef ALLEGRO_MACOSX
4456
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4457
4458
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4459 #else
4460 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4461
4462 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4463 #endif
4464
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3587339 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4465
4466
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if (zc_read_system_key(KEY_F12))
4467 {
4468 onSnapshot();
4469 }
4470
4471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3587339 if(debug_enabled && zc_read_system_key(KEY_TAB))
4472 set_debug(!get_debug());
4473
4474
3/4
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 3568609 times.
3587339 if(get_debug() || cheat>=1)
4475 {
4476
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4477 {
4478 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4479
4480 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4481
4482 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4483
4484 if(zc_readkey(KEY_B))
4485 {
4486 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4487 }
4488
4489 if(zc_readkey(KEY_A))
4490 {
4491 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4492 }
4493 }
4494 18730 }
4495
4496
3/4
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 3568609 times.
3587339 if(get_debug() || cheat>=2)
4497 {
4498
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4499 {
4500 if(rI())
4501 {
4502 cheats_enqueue(Cheat::Clock);
4503 }
4504 }
4505 18730 }
4506
4507
3/4
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 3568609 times.
3587339 if(get_debug() || cheat>=4)
4508 {
4509
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4510 {
4511 if(rF11())
4512 {
4513 cheats_enqueue(Cheat::Walls);
4514 }
4515
4516 if(rQ())
4517 {
4518 cheats_enqueue(Cheat::Fast);
4519 }
4520
4521 if(zc_readkey(KEY_F))
4522 {
4523 cheats_enqueue(Cheat::Freeze);
4524 }
4525
4526 if(zc_readkey(KEY_G)) onGoToComplete();
4527
4528 if(zc_readkey(KEY_0)) onShowLayer0();
4529
4530 if(zc_readkey(KEY_1)) onShowLayer1();
4531
4532 if(zc_readkey(KEY_2)) onShowLayer2();
4533
4534 if(zc_readkey(KEY_3)) onShowLayer3();
4535
4536 if(zc_readkey(KEY_4)) onShowLayer4();
4537
4538 if(zc_readkey(KEY_5)) onShowLayer5();
4539
4540 if(zc_readkey(KEY_6)) onShowLayer6();
4541
4542 //if(zc_readkey(KEY_7)) onShowLayerO();
4543 if(zc_readkey(KEY_7)) onShowLayerF();
4544
4545 if(zc_readkey(KEY_8)) onShowLayerS();
4546
4547 if(zc_readkey(KEY_W)) onShowLayerW();
4548
4549 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4550
4551 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4552
4553 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4554 if(zc_readkey(KEY_O)) onShowLayerO();
4555 if(zc_readkey(KEY_P)) onShowLayerP();
4556 if(zc_readkey(KEY_C)) onShowHitboxes();
4557 if(zc_readkey(KEY_F)) onShowFFScripts();
4558 }
4559 18730 }
4560
4561
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(volkeys)
4562 {
4563 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4564
4565 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4566
4567 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4568
4569 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4570 }
4571
4572
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3587339 if(!get_debug() || !SystemKeys || replay_is_replaying())
4573 3587339 goto bottom;
4574
4575 if(zc_readkey(KEY_D))
4576 {
4577 details = !details;
4578 rectfill(screen,0,0,319,7,BLACK);
4579 rectfill(screen,0,8,31,239,BLACK);
4580 rectfill(screen,288,8,319,239,BLACK);
4581 rectfill(screen,32,232,287,239,BLACK);
4582 }
4583
4584 if(zc_readkey(KEY_P)) Paused=!Paused;
4585
4586 //if(zc_readkey(KEY_P)) centerHero();
4587 if(zc_readkey(KEY_A))
4588 {
4589 Paused=true;
4590 Advance=true;
4591 }
4592
4593 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4594 #ifndef ALLEGRO_MACOSX
4595 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4596
4597 if(zc_readkey(KEY_F7))
4598 {
4599 Matrix(ss_speed, ss_density, 0);
4600 game_pal();
4601 }
4602 #else
4603 // The reason these are different on Mac in the first place is that
4604 // the OS doesn't let us use F9 and F10...
4605 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4606
4607 if(zc_readkey(KEY_F9))
4608 {
4609 Matrix(ss_speed, ss_density, 0);
4610 game_pal();
4611 }
4612 #endif
4613 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4614 {
4615 //change containers
4616 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4617 {
4618 //magic containers
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4622 }
4623 else
4624 {
4625 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4626 }
4627 }
4628 else
4629 {
4630 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4631 {
4632 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4633 }
4634 else
4635 {
4636 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4637 }
4638 }
4639 }
4640
4641 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4642 {
4643 //change containers
4644 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4645 {
4646 //magic containers
4647 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4648 {
4649 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4650 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4651 //heart containers
4652 }
4653 else
4654 {
4655 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4656 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4657 }
4658 }
4659 else
4660 {
4661 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4662 {
4663 game->set_magic(zc_max(game->get_magic()-1,0));
4664 }
4665 else
4666 {
4667 game->set_life(zc_max(game->get_life()-1,0));
4668 }
4669 }
4670 }
4671
4672 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4673
4674 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4675
4676 verifyBothWeapons();
4677
4678 bottom:
4679
4680
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(input_idle(true) > after_time())
4681 {
4682 Matrix(ss_speed, ss_density, 0);
4683 game_pal();
4684 }
4685 //Saffith's method of separating system and game key bindings. Can't do this!!
4686 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4687
4688 //while(Playing && keypressed())
4689 //readkey();
4690 // What's the Playing check for?
4691 3587339 clear_keybuf();
4692 3587339 }
4693
4694 13384240 void checkQuitKeys()
4695 {
4696 #ifndef ALLEGRO_MACOSX
4697
1/2
✓ Branch 0 taken 13384240 times.
✗ Branch 1 not taken.
13384240 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4698
4699
1/2
✓ Branch 0 taken 13384240 times.
✗ Branch 1 not taken.
13384240 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4700 #else
4701 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4702
4703 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4704 #endif
4705 13384240 }
4706
4707 56190 bool CheatModifierKeys()
4708 {
4709 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4710 // to trigger cheats.
4711
1/2
✓ Branch 0 taken 56190 times.
✗ Branch 1 not taken.
56190 if (replay_is_replaying())
4712 56190 return false;
4713
4714 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4715 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4716 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4717 {
4718 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4719 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4720 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4721 {
4722 return true;
4723 }
4724 }
4725 return false;
4726 56190 }
4727
4728 //99:05:54, for some reason?
4729 #define OLDMAXTIME 21405240
4730 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4731 #define MAXTIME 1944000000
4732
4733 3536194 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4734 {
4735
2/2
✓ Branch 0 taken 3282369 times.
✓ Branch 1 taken 253825 times.
3536194 if(zcmusic!=NULL)
4736 {
4737 253825 zcmusic_poll();
4738 253825 }
4739
4740
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3536194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3536194 times.
3536194 while(Paused && !Advance && !Quit)
4741 {
4742 // have to call this, otherwise we'll get an infinite loop
4743 syskeys();
4744 if(allowF6Script)
4745 {
4746 FFCore.runF6Engine();
4747 }
4748 if (replay_get_mode() != ReplayMode::Assert)
4749 updatescr(allowwavy);
4750 throttleFPS();
4751
4752 #ifdef _WIN32
4753
4754 if(use_dwm_flush)
4755 {
4756 do_DwmFlush();
4757 }
4758
4759 #endif
4760
4761 // to keep music playing
4762 if(zcmusic!=NULL)
4763 {
4764 zcmusic_poll();
4765 }
4766
4767 update_hw_screen();
4768 }
4769
4770
2/2
✓ Branch 0 taken 3536180 times.
✓ Branch 1 taken 14 times.
3536194 if(Quit)
4771 14 return;
4772
4773
3/4
✓ Branch 0 taken 3508891 times.
✓ Branch 1 taken 27289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3508891 times.
3536180 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4774 3508891 game->change_time(1);
4775
4776 3536180 Advance=false;
4777
4778 3536180 updatescr(allowwavy);
4779
4780
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3536177 times.
3536180 if (replay_is_active())
4781 {
4782
2/2
✓ Branch 0 taken 1270460 times.
✓ Branch 1 taken 2265717 times.
3536177 if (replay_get_version() >= 3)
4783 2265717 replay_poll();
4784
4785 // Replay compatability.
4786
4/4
✓ Branch 0 taken 115525 times.
✓ Branch 1 taken 3420652 times.
✓ Branch 2 taken 14990 times.
✓ Branch 3 taken 100535 times.
3536177 if (replay_get_version() >= 6 && replay_get_version() < 8)
4787 100535 replay_peek_input();
4788
2/2
✓ Branch 0 taken 14990 times.
✓ Branch 1 taken 3521187 times.
3536177 if (replay_get_version() < 8)
4789 3521187 update_keys();
4790 3536177 }
4791
4792 3536180 ++frame;
4793
4794
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3536177 times.
3536180 if (replay_is_replaying())
4795 3536177 replay_do_cheats();
4796 3536180 syskeys();
4797
4798 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4799 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4800 // approach here means it doesn't matter which call adds the cheat.
4801 3536180 cheats_execute_queued();
4802
4803
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3536177 times.
3536180 if (replay_is_replaying())
4804 3536177 replay_peek_quit();
4805
2/2
✓ Branch 0 taken 3536166 times.
✓ Branch 1 taken 14 times.
3536180 if (GameFlags & GAMEFLAG_TRYQUIT)
4806 14 replay_step_quit(0);
4807
2/2
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 3535082 times.
3536180 if(allowF6Script)
4808 {
4809 3535082 FFCore.runF6Engine();
4810 3535082 }
4811
2/2
✓ Branch 0 taken 3536078 times.
✓ Branch 1 taken 102 times.
3536180 if (Quit)
4812 102 replay_step_quit(Quit);
4813 // Someday... maybe install a Turbo button here?
4814 3536180 throttleFPS();
4815
4816 #ifdef _WIN32
4817
4818 if(use_dwm_flush)
4819 {
4820 do_DwmFlush();
4821 }
4822
4823 #endif
4824
4825 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4826
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3535881 times.
3536180 if(sfxcleanup)
4827 3535881 sfx_cleanup();
4828 3536194 }
4829
4830 8 void zapout()
4831 {
4832 8 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4833 8 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4834
4835 8 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4836 8 script_drawing_commands.Clear();
4837
4838 // zap out
4839
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
200 for(int32_t i=1; i<=24; i++)
4840 {
4841 192 draw_fuzzy(i);
4842 192 syskeys();
4843 192 advanceframe(true);
4844
4845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(Quit)
4846 {
4847 break;
4848 }
4849 192 }
4850 8 }
4851
4852 8 void zapin()
4853 {
4854 8 FFCore.warpScriptCheck();
4855 8 draw_screen(tmpscr);
4856 8 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4857 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4858 8 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4859
4860 // zap out
4861 8 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4862
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
200 for(int32_t i=24; i>=1; i--)
4863 {
4864 192 draw_fuzzy(i);
4865 192 syskeys();
4866 192 advanceframe(true);
4867
4868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(Quit)
4869 {
4870 break;
4871 }
4872 192 }
4873 8 }
4874
4875
4876 void wavyout(bool showhero)
4877 {
4878 draw_screen(tmpscr, showhero);
4879 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4880
4881 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4882 clear_to_color(wavebuf,0);
4883 blit(framebuf,wavebuf,0,0,16,0,256,224);
4884
4885 static PALETTE wavepal;
4886
4887 int32_t ofs;
4888 int32_t amplitude=8;
4889
4890 int32_t wavelength=4;
4891 double palpos=0, palstep=4, palstop=126;
4892
4893 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4894 for(int32_t i=0; i<168; i+=wavelength)
4895 {
4896 for(int32_t l=0; l<256; l++)
4897 {
4898 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4899 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4900 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4901 }
4902
4903 palpos+=palstep;
4904
4905 if(palpos>=0)
4906 {
4907 hw_palette = &wavepal;
4908 update_hw_pal = true;
4909 }
4910 else
4911 {
4912 hw_palette = &RAMpal;
4913 update_hw_pal = true;
4914 }
4915
4916 for(int32_t j=0; j+playing_field_offset<224; j++)
4917 {
4918 for(int32_t k=0; k<256; k++)
4919 {
4920 ofs=0;
4921
4922 if((j<i)&&(j&1))
4923 {
4924 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4925 }
4926
4927 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4928 }
4929 }
4930
4931 syskeys();
4932 advanceframe(true);
4933
4934 // animate_combos();
4935 if(Quit)
4936 break;
4937 }
4938
4939 destroy_bitmap(wavebuf);
4940 }
4941
4942 void wavyin()
4943 {
4944 draw_screen(tmpscr);
4945 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4946
4947 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4948 clear_to_color(wavebuf,0);
4949 blit(framebuf,wavebuf,0,0,16,0,256,224);
4950
4951 static PALETTE wavepal;
4952
4953 //Breaks dark rooms.
4954 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4955 /*
4956 loadfullpal();
4957 loadlvlpal(DMaps[currdmap].color);
4958 ringcolor(false);
4959 */
4960 refreshpal=false;
4961 int32_t ofs;
4962 int32_t amplitude=8;
4963 int32_t wavelength=4;
4964 double palpos=168, palstep=4, palstop=126;
4965
4966 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4967 for(int32_t i=0; i<168; i+=wavelength)
4968 {
4969 for(int32_t l=0; l<256; l++)
4970 {
4971 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4972 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4973 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4974 }
4975
4976 palpos-=palstep;
4977
4978 if(palpos>=0)
4979 {
4980 hw_palette = &wavepal;
4981 update_hw_pal = true;
4982 }
4983 else
4984 {
4985 hw_palette = &RAMpal;
4986 update_hw_pal = true;
4987 }
4988
4989 for(int32_t j=0; j+playing_field_offset<224; j++)
4990 {
4991 for(int32_t k=0; k<256; k++)
4992 {
4993 ofs=0;
4994
4995 if((j<(167-i))&&(j&1))
4996 {
4997 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4998 }
4999
5000 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5001 }
5002 }
5003
5004 syskeys();
5005 advanceframe(true);
5006 // animate_combos();
5007
5008 if(Quit)
5009 break;
5010 }
5011
5012 destroy_bitmap(wavebuf);
5013 }
5014
5015 1086 void blackscr(int32_t fcnt,bool showsubscr)
5016 {
5017 1086 reset_pal_cycling();
5018 1086 script_drawing_commands.Clear();
5019
5020 1086 FFCore.warpScriptCheck();
5021 1086 bool showtime = game->should_show_time();
5022
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 32510 times.
33596 while(fcnt>0)
5023 {
5024 32510 clear_bitmap(framebuf);
5025
5026
2/2
✓ Branch 0 taken 8340 times.
✓ Branch 1 taken 24170 times.
32510 if(showsubscr)
5027 {
5028 24170 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5029
3/4
✓ Branch 0 taken 24170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 23420 times.
24170 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5030 {
5031 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5032 750 }
5033 24170 }
5034
5035 32510 syskeys();
5036 32510 advanceframe(true);
5037
5038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32510 times.
32510 if(Quit)
5039 break;
5040
5041 32510 --fcnt;
5042 }
5043 1086 }
5044
5045 256 void openscreen(int32_t shape)
5046 {
5047 256 reset_pal_cycling();
5048 256 black_opening_count=0;
5049
5050
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 158 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
256 if(COOLSCROLL || shape>-1)
5051 {
5052 158 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5053 158 return;
5054 }
5055 else
5056 {
5057 98 Hero.setDontDraw(true);
5058 98 show_subscreen_dmap_dots=false;
5059 98 show_subscreen_numbers=false;
5060 // show_subscreen_items=false;
5061 98 show_subscreen_life=false;
5062 }
5063
5064 98 int32_t x=128;
5065
5066 98 FFCore.warpScriptCheck();
5067
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5068 {
5069 7840 draw_screen(tmpscr);
5070 //? draw_screen already draws the subscreen -DD
5071 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5072 7840 x=128-(((i*128/80)/8)*8);
5073
5074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5075 {
5076 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5077 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5078 7840 }
5079
5080 // x=((80-i)/2)*4;
5081 /*
5082 --x;
5083 switch(++c)
5084 {
5085 case 5: c=0;
5086 case 0:
5087 case 2:
5088 case 3: --x; break;
5089 }
5090 */
5091 7840 syskeys();
5092 7840 advanceframe(true);
5093
5094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5095 {
5096 break;
5097 }
5098 7840 }
5099
5100 98 Hero.setDontDraw(false);
5101 98 show_subscreen_items=true;
5102 98 show_subscreen_dmap_dots=true;
5103 256 }
5104
5105 void closescreen(int32_t shape)
5106 {
5107 reset_pal_cycling();
5108 black_opening_count=0;
5109
5110 if(COOLSCROLL || shape>-1)
5111 {
5112 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5113 return;
5114 }
5115 else
5116 {
5117 Hero.setDontDraw(true);
5118 show_subscreen_dmap_dots=false;
5119 show_subscreen_numbers=false;
5120 // show_subscreen_items=false;
5121 show_subscreen_life=false;
5122 }
5123
5124 int32_t x=128;
5125
5126 FFCore.warpScriptCheck();
5127 for(int32_t i=79; i>=0; --i)
5128 {
5129 draw_screen(tmpscr);
5130 //? draw_screen already draws the subscreen -DD
5131 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5132 x=128-(((i*128/80)/8)*8);
5133
5134 if(x>0)
5135 {
5136 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5137 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5138 }
5139
5140 // x=((80-i)/2)*4;
5141 /*
5142 --x;
5143 switch(++c)
5144 {
5145 case 5: c=0;
5146 case 0:
5147 case 2:
5148 case 3: --x; break;
5149 }
5150 */
5151 syskeys();
5152 advanceframe(true);
5153
5154 if(Quit)
5155 {
5156 break;
5157 }
5158 }
5159
5160 Hero.setDontDraw(false);
5161 show_subscreen_items=true;
5162 show_subscreen_dmap_dots=true;
5163 }
5164
5165 75 int32_t TriforceCount()
5166 {
5167 75 int32_t c=0;
5168
5169
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 75 times.
675 for(int32_t i=1; i<=8; i++)
5170
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 357 times.
957 if(game->lvlitems[i]&liTRIFORCE)
5171 357 ++c;
5172
5173 75 return c;
5174 }
5175
5176 int32_t onCustomGame()
5177 {
5178 int32_t file = getsaveslot();
5179
5180 if(file < 0)
5181 return D_O_K;
5182
5183 bool ret = (custom_game(file)!=0);
5184 return ret ? D_CLOSE : D_O_K;
5185 }
5186
5187 int32_t onContinue()
5188 {
5189 return D_CLOSE;
5190 }
5191
5192 int32_t onEsc() // Unused?? -L
5193 {
5194 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5195 }
5196
5197 int32_t onVsync()
5198 {
5199 Throttlefps = !Throttlefps;
5200 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5201 return D_O_K;
5202 }
5203
5204 int32_t onWinPosSave()
5205 {
5206 SaveWinPos = !SaveWinPos;
5207 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5208 return D_O_K;
5209 }
5210
5211 int32_t onClickToFreeze()
5212 {
5213 ClickToFreeze = !ClickToFreeze;
5214 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5215 return D_O_K;
5216 }
5217
5218 int32_t OnSaveZCConfig()
5219 {
5220 if(jwin_alert3(
5221 "Save Configuration",
5222 "Are you sure that you wish to save your present configuration settings?",
5223 "This will overwrite your prior settings!",
5224 NULL,
5225 "&Yes",
5226 "&No",
5227 NULL,
5228 'y',
5229 'n',
5230 0,
5231 lfont) == 1)
5232 {
5233 save_game_configs();
5234 return D_O_K;
5235 }
5236 else return D_O_K;
5237 }
5238
5239 int32_t OnnClearQuestDir()
5240 {
5241 if(jwin_alert3(
5242 "Clear Current Directory Cache",
5243 "Are you sure that you wish to clear the current cached directory?",
5244 "This will default the current directory to the ROOT for this instance of ZC Player!",
5245 NULL,
5246 "&Yes",
5247 "&No",
5248 NULL,
5249 'y',
5250 'n',
5251 0,
5252 lfont) == 1)
5253 {
5254 zc_set_config("zeldadx","win_qst_dir","");
5255 flush_config_file();
5256 strcpy(qstdir,"");
5257 #ifdef __EMSCRIPTEN__
5258 em_sync_fs();
5259 #endif
5260 return D_O_K;
5261 }
5262 else return D_O_K;
5263 }
5264
5265
5266 int32_t onConsoleZASM()
5267 {
5268 if ( !zasm_debugger )
5269 {
5270 AlertDialog("WARNING: ZASM Debugger",
5271 "Enabling this will open the ZASM Debugger Console"
5272 "\nThis will likely grind ZC to a halt with lag."
5273 "\nTo make any use of this, it is suggested that you read"
5274 "\nthe documentation for 'void Breakpoint(char[] string);'"
5275 " in 'ZScript_Additions.txt'"
5276 "\nThis is not recommended for normal users,"
5277 " and is only intended for ZC developers,"
5278 "\nor quest developers coding directly in ZASM"
5279 "\nAre you sure that you wish to open the ZASM Debugger?",
5280 [&](bool ret,bool)
5281 {
5282 if(ret)
5283 {
5284 FFCore.ZASMPrint(true);
5285 }
5286 }).show();
5287 return D_O_K;
5288 }
5289 else
5290 {
5291 FFCore.ZASMPrint(false);
5292 return D_O_K;
5293 }
5294 }
5295
5296
5297 int32_t onConsoleZScript()
5298 {
5299 if ( !zscript_debugger )
5300 {
5301 AlertDialog("ZScript Debugger",
5302 "Enabling this will open the ZScript Debugger Console"
5303 "\nThis will display any messages logged by scripts,"
5304 " including script errors."
5305 "\nAre you sure that you wish to open the ZScript Debugger?",
5306 [&](bool ret,bool)
5307 {
5308 if(ret)
5309 {
5310 FFCore.ZScriptConsole(true);
5311 }
5312 }).show();
5313 return D_O_K;
5314 }
5315 else
5316 {
5317 FFCore.ZScriptConsole(false);
5318 return D_O_K;
5319 }
5320 }
5321
5322 int32_t onClrConsoleOnLoad()
5323 {
5324 clearConsoleOnLoad = !clearConsoleOnLoad;
5325 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5326 return D_O_K;
5327 }
5328
5329
5330 int32_t onFrameSkip()
5331 {
5332 FrameSkip = !FrameSkip;
5333 return D_O_K;
5334 }
5335
5336 int32_t onSaveDragResize()
5337 {
5338 SaveDragResize = !SaveDragResize;
5339 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5340 return D_O_K;
5341 }
5342
5343 int32_t onDragAspect()
5344 {
5345 DragAspect = !DragAspect;
5346 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5347 return D_O_K;
5348 }
5349
5350 int32_t onTransLayers()
5351 {
5352 TransLayers = !TransLayers;
5353 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5354 return D_O_K;
5355 }
5356
5357 int32_t onNESquit()
5358 {
5359 NESquit = !NESquit;
5360 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5361 return D_O_K;
5362 }
5363
5364 int32_t onVolKeys()
5365 {
5366 volkeys = !volkeys;
5367 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5368 return D_O_K;
5369 }
5370
5371 int32_t onShowFPS()
5372 {
5373 ShowFPS = !ShowFPS;
5374 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5375 return D_O_K;
5376 }
5377
5378 423306002 bool is_Fkey(int32_t k)
5379 {
5380
2/2
✓ Branch 0 taken 43048068 times.
✓ Branch 1 taken 380257934 times.
423306002 switch(k)
5381 {
5382 case KEY_F1:
5383 case KEY_F2:
5384 case KEY_F3:
5385 case KEY_F4:
5386 case KEY_F5:
5387 case KEY_F6:
5388 case KEY_F7:
5389 case KEY_F8:
5390 case KEY_F9:
5391 case KEY_F10:
5392 case KEY_F11:
5393 case KEY_F12:
5394 43048068 return true;
5395 }
5396
5397 380257934 return false;
5398 423306002 }
5399
5400 void kb_getkey(DIALOG *d)
5401 {
5402 d->flags|=D_SELECTED;
5403
5404 scare_mouse();
5405 jwin_button_proc(MSG_DRAW,d,0);
5406 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5407 // text_mode(vc(11));
5408 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5410 unscare_mouse();
5411
5412 update_hw_screen(true);
5413
5414 clear_keybuf();
5415 int32_t k = next_press_key();
5416 clear_keybuf();
5417
5418 //shnarf
5419 //47=f1
5420 //59=esc
5421 if(k>0 && k<123 && !((k>46)&&(k<60)))
5422 *((int32_t*)d->dp3) = k;
5423
5424
5425 d->flags&=~D_SELECTED;
5426 }
5427
5428
5429 //Used by all keyboard key settings dialogues.
5430 void kb_clearjoystick(DIALOG *d)
5431 {
5432 d->flags|=D_SELECTED;
5433
5434 scare_mouse();
5435 jwin_button_proc(MSG_DRAW,d,0);
5436 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5437 // text_mode(vc(11));
5438 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5439 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5440 unscare_mouse();
5441
5442 update_hw_screen(true);
5443
5444 clear_keybuf();
5445 int32_t k = next_press_key();
5446 clear_keybuf();
5447
5448 //shnarf
5449 //47=f1
5450 //59=esc
5451 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5452 // *((int32_t*)d->dp3) = k;
5453 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5454
5455
5456 d->flags&=~D_SELECTED;
5457 }
5458
5459 //Clears key to 0.
5460 //Used by all keyboard key settings dialogues.
5461 void kb_clearkey(DIALOG *d)
5462 {
5463 d->flags|=D_SELECTED;
5464
5465 scare_mouse();
5466 jwin_button_proc(MSG_DRAW,d,0);
5467 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5468 // text_mode(vc(11));
5469 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5470 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5471 unscare_mouse();
5472
5473 update_hw_screen(true);
5474
5475 clear_keybuf();
5476 int32_t k = next_press_key();
5477 clear_keybuf();
5478
5479 //shnarf
5480 //47=f1
5481 //59=esc
5482 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5483 // *((int32_t*)d->dp3) = k;
5484 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5485
5486
5487 d->flags&=~D_SELECTED;
5488 }
5489
5490
5491 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5492 {
5493 switch(msg)
5494 {
5495 case MSG_KEY:
5496 case MSG_CLICK:
5497
5498 kb_clearjoystick(d);
5499
5500 while(gui_mouse_b())
5501 {
5502 clear_keybuf();
5503 rest(1);
5504 }
5505
5506 return D_REDRAW;
5507 }
5508
5509 return jwin_button_proc(msg,d,c);
5510 }
5511
5512 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5513 {
5514 switch(msg)
5515 {
5516 case MSG_KEY:
5517 case MSG_CLICK:
5518
5519 kb_getkey(d);
5520
5521 while(gui_mouse_b()) {
5522 clear_keybuf();
5523 rest(1);
5524 }
5525
5526 return D_REDRAW;
5527 }
5528
5529 return jwin_button_proc(msg,d,c);
5530 }
5531
5532 //Only used in keyboard settings dialogues to clear keys.
5533 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5534 {
5535 switch(msg)
5536 {
5537 case MSG_KEY:
5538 case MSG_CLICK:
5539
5540 kb_clearkey(d);
5541
5542 while(gui_mouse_b()) {
5543 clear_keybuf();
5544 rest(1);
5545 }
5546
5547 return D_REDRAW;
5548 }
5549
5550 return jwin_button_proc(msg,d,c);
5551 }
5552
5553 void j_getbtn(DIALOG *d)
5554 {
5555 d->flags|=D_SELECTED;
5556 scare_mouse();
5557 jwin_button_proc(MSG_DRAW,d,0);
5558 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5559 // text_mode(vc(11));
5560 int32_t y = gui_bmp->h/2 - 12;
5561 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5562 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5563 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5564 unscare_mouse();
5565
5566 update_hw_screen(true);
5567
5568 int32_t b = next_press_btn();
5569
5570 if(b>=0)
5571 *((int32_t*)d->dp3) = b;
5572
5573 d->flags&=~D_SELECTED;
5574
5575 if (player)
5576 player->joy_on = TRUE;
5577 }
5578
5579 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5580 {
5581 switch(msg)
5582 {
5583 case MSG_KEY:
5584 case MSG_CLICK:
5585
5586 j_getbtn(d);
5587
5588 while(gui_mouse_b()) {
5589 rest(1);
5590 clear_keybuf();
5591 }
5592
5593 return D_REDRAW;
5594 }
5595
5596 return jwin_button_proc(msg,d,c);
5597 }
5598
5599 //shnarf
5600 const char *key_str[] =
5601 {
5602 "(none) ", "a ", "b ", "c ",
5603 "d ", "e ", "f ", "g ",
5604 "h ", "i ", "j ", "k ",
5605 "l ", "m ", "n ", "o ",
5606 "p ", "q ", "r ", "s ",
5607 "t ", "u ", "v ", "w ",
5608 "x ", "y ", "z ", "0 ",
5609 "1 ", "2 ", "3 ", "4 ",
5610 "5 ", "6 ", "7 ", "8 ",
5611 "9 ", "num 0 ", "num 1 ", "num 2 ",
5612 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5613 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5614 "f2 ", "f3 ", "f4 ", "f5 ",
5615 "f6 ", "f7 ", "f8 ", "f9 ",
5616 "f10 ", "f11 ", "f12 ", "esc ",
5617 "~ ", "- ", "= ", "backspace ",
5618 "tab ", "{ ", "} ", "enter ",
5619 ": ", "quote ", "\\ ", "\\ (2) ",
5620 ", ", ". ", "/ ", "space ",
5621 "insert ", "delete ", "home ", "end ",
5622 "page up ", "page down ", "left ", "right ",
5623 "up ", "down ", "num / ", "num * ",
5624 "num - ", "num + ", "num delete ", "num enter ",
5625 "print screen ", "pause ", "abnt c1 ", "yen ",
5626 "kana ", "convert ", "no convert ", "at ",
5627 "circumflex ", ": (2) ", "kanji ", "num = ",
5628 "back quote ", "; ", "command ", "unknown (0) ",
5629 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5630 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5631 "right shift ", "left control ", "right control", "alt ",
5632 "alt gr ", "left win ", "right win ", "menu ",
5633 "scroll lock ", "number lock ", "caps lock ", "MAX"
5634 };
5635
5636
5637 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5638 //extern int32_t zcmusic_bufsz;
5639
5640 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5641 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5642
5643 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5644 {
5645 //these are here to bypass compiler warnings about unused arguments
5646 c=c;
5647
5648 if(msg==MSG_DRAW)
5649 {
5650 switch(d->w)
5651 {
5652 case 0:
5653 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5654 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5655 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5656 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5657 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5658 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5659 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5660 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5661 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5662 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5663 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5664 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5665 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5666 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5667 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5668 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5669 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5670 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5671 break;
5672
5673 case 1:
5674 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5675 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5676 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5677 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5678 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5679 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5680 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5681 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5682 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5683 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5684 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5685 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5686 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5687 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5688 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5689 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5690 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5691 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5692 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5693 break;
5694
5695 case 2:
5696 sprintf(str_a," %3d",midi_volume);
5697 sprintf(str_b," %3d",digi_volume);
5698 sprintf(str_l," %3d",emusic_volume);
5699 sprintf(str_m," %3dKB",zcmusic_bufsz);
5700 sprintf(str_r," %3d",sfx_volume);
5701 strcpy(str_s,pan_str[pan_style]);
5702 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5703 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5704 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5705 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5706 break;
5707 }
5708 }
5709
5710 return D_O_K;
5711 }
5712
5713 int32_t set_vol(void *dp3, int32_t d2)
5714 {
5715 switch(((int32_t*)dp3)[0])
5716 {
5717 case 0:
5718 midi_volume = zc_min(d2<<3,255);
5719 break;
5720
5721 case 1:
5722 digi_volume = zc_min(d2<<3,255);
5723 break;
5724
5725 case 2:
5726 emusic_volume = zc_min(d2<<3,255);
5727 break;
5728
5729 case 3:
5730 sfx_volume = zc_min(d2<<3,255);
5731 break;
5732 }
5733
5734 scare_mouse();
5735 // text_mode(vc(11));
5736 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5737 unscare_mouse();
5738 return D_O_K;
5739 }
5740
5741 int32_t set_pan(void *dp3, int32_t d2)
5742 {
5743 pan_style = vbound(d2,0,3);
5744 scare_mouse();
5745 // text_mode(vc(11));
5746 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5747 unscare_mouse();
5748 return D_O_K;
5749 }
5750
5751 int32_t set_buf(void *dp3, int32_t d2)
5752 {
5753 scare_mouse();
5754 // text_mode(vc(11));
5755 zcmusic_bufsz = d2 + 1;
5756 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5757 unscare_mouse();
5758 return D_O_K;
5759 }
5760
5761 static int32_t gamepad_btn_list[] =
5762 {
5763 6,
5764 7,8,9,10,11,12,13,14,15,16,17,
5765 18,19,20,21,22,23,24,25,26,27,28,
5766 29,30,31,32,33,34,35,36,37,38,39,
5767 -1
5768 };
5769
5770 static int32_t gamepad_dirs_list[] =
5771 {
5772 40,41,42,43,
5773 44,45,46,47,
5774 48,49,50,51,
5775 52,53,54,55,
5776 56,
5777 -1
5778 };
5779
5780 static TABPANEL gamepad_tabs[] =
5781 {
5782 // (text)
5783 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5784 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5785 { NULL, 0, NULL, 0, NULL }
5786 };
5787
5788 static DIALOG gamepad_dlg[] =
5789 {
5790 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5791 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5792 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5793 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5794 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5795 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5796 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5797 // 6
5798 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 // 7
5800 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5801 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5802 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5803 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5804 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5805 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5806 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5807 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5808 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5809 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5810 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5811 // 18
5812 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5813 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5814 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5815 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5816 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5817 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5818 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5819 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5820 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5821 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5822 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5823 // 29
5824 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5825 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5826 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5827 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5828 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5829 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5830 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5831 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5832 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5833 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5834 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5835 // 40
5836 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5837 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5838 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5839 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5840 // 44
5841 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5842 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5843 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5844 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5845 // 48
5846 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5847 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5848 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5849 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5850 // 52
5851 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5852 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5853 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5854 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5855 // 56
5856 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5857 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5858 };
5859
5860 static int32_t keyboard_keys_list[] =
5861 {
5862 6,7,8,9,10,
5863 11,12,13,14,15,16,17,18,19,20,
5864 21,22,23,24,25,26,27,28,29,30,
5865 31,32,33,34,35,36,37,38,39,40,
5866 -1
5867 };
5868
5869 static int32_t keyboard_dirs_list[] =
5870 {
5871 41,42,43,44,
5872 45,46,47,48,
5873 49,50,51,52,
5874 53,54,55,56,
5875 -1
5876 };
5877
5878 static int32_t keyboard_mods_list[] =
5879 {
5880 57,58,59,60,
5881 61,62,63,64,
5882 65,66,67,68,
5883 69,70,71,72,
5884 -1
5885 };
5886
5887 static TABPANEL keyboard_control_tabs[] =
5888 {
5889 // (text)
5890 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5891 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5892 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5893 { NULL, 0, NULL, 0, NULL }
5894 };
5895
5896 static DIALOG keyboard_control_dlg[] =
5897 {
5898 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5899 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5900 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5901 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5902 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5903 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5904 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5905 // Keys
5906 // 6
5907 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5908 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5909 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5910 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5911 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5912 // 11
5913 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5914 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5915 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5916 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5917 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5918 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5919 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5920 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5921 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5922 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5923 // 21
5924 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5925 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5926 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5927 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5928 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5929 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5930 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5931 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5932 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5933 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5934 // 31
5935 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5936 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5937 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5938 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5939 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5940 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5941 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5942 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5943 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5944 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5945 // Dirs
5946 // 41
5947 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5948 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5949 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5950 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5951 // 45
5952 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5953 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5954 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5955 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5956 // 49
5957 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5958 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5959 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5960 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5961 // 53
5962 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5963 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5964 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5965 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5966 // Mods
5967 // 57
5968 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5969 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5970 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5971 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5972 // 61
5973 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5974 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5975 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5976 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5977 // 65
5978 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5979 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5980 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5981 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5982 // 69
5983 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5984 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5985 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5986 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5987 // 73
5988 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5989 };
5990
5991 /*
5992 int32_t midi_dp[3] = {0,147,104};
5993 int32_t digi_dp[3] = {1,147,120};
5994 int32_t pan_dp[3] = {0,147,136};
5995 int32_t buf_dp[3] = {0,147,152};
5996 */
5997 int32_t midi_dp[3] = {0,0,0};
5998 int32_t digi_dp[3] = {1,0,0};
5999 int32_t emus_dp[3] = {2,0,0};
6000 int32_t buf_dp[3] = {0,0,0};
6001 int32_t sfx_dp[3] = {3,0,0};
6002 int32_t pan_dp[3] = {0,0,0};
6003
6004 static DIALOG sound_dlg[] =
6005 {
6006 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6007 14 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6008 14 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 14 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6010 14 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6011 14 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6012 14 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6013 14 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6014 14 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6015 14 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6016 14 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6017 // 10
6018 14 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6019 14 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6020 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6021 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6022 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6023 14 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6024 14 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6025 14 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6026 14 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6027 14 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6028 //20
6029 14 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6030 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6031 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6032 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6033 14 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6034 14 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6035 14 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6036 14 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6037 14 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6038 14 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6039 //30
6040 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6041 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6042 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6043 14 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6044 };
6045
6046 char zc_builddate[80];
6047 char zc_aboutstr[80];
6048
6049 static DIALOG about_dlg[] =
6050 {
6051 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6052 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6053 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6054 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6055 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6056 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6057 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6058 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6059 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6060 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6061 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6062 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6063 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6064 };
6065
6066
6067 static DIALOG quest_dlg[] =
6068 {
6069 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6070 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6071 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6072 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6073 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6074 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6075 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6076 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6077 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6078 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6079 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6080 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6081 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6082 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6083 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6084 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6085 };
6086
6087 static DIALOG triforce_dlg[] =
6088 {
6089 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6090 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6091 // 1
6092 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6093 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6094 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6095 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6096 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6097 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6098 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6099 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6100 // 9
6101 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6102 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6103 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6104 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6105 };
6106
6107 /*static DIALOG equip_dlg[] =
6108 {
6109 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6110 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6111 // 1
6112 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6113 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6114 // 3
6115 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6116 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6117 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6118 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6119 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6120 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6121 // 9
6122 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6123 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6124 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6125 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6126 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6127 // 14
6128 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6129 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6130 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6131 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6132 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6133 // 19
6134 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6135 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6136 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6137 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6138 // 23
6139 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6140 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6141 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6142 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6143 // 27
6144 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6145 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6146 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6147 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6148 // 31
6149 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6150 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6151 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6152 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6153 // 35
6154 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6155 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6156 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6157 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6158 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6159 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6160 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6161 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6162 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6163 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6164 };
6165
6166 static DIALOG items_dlg[] =
6167 {
6168 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6169 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6170 //1
6171 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6172 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6173 // 3
6174 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6175 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6176 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6177 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6178 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6179 // 8
6180 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6181 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6182 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6183 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6184 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6185 // 13
6186 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6187 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6188 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6189 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6190 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6191 // 18
6192 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6193 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6194 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6195 // 21
6196 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6197 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6198 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6199 // 24
6200 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6201 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6202 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6203 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6204 // 28
6205 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6206 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6207 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6208 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6209 // 32
6210 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6211 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6212 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6213 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6214 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6215 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6216 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6217 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6218 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6219 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6220 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6221 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6222 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6223 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6224 //45
6225 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6226 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6227 };*/
6228
6229
6230
6231 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6232 {
6233 go();
6234 int32_t ret=0;
6235 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6236 comeback();
6237 return ret != 0;
6238 }
6239
6240
6241 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6242 {
6243 if(def!=modulepath)
6244 strcpy(modulepath,def);
6245
6246 if(!usefilename)
6247 {
6248 int32_t i=(int32_t)strlen(modulepath);
6249
6250 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6251 modulepath[i--]=0;
6252 }
6253
6254 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6255 int32_t ret=0;
6256 int32_t sel=0;
6257
6258 if(list==NULL)
6259 {
6260 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6261 }
6262 else
6263 {
6264 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6265 }
6266
6267 return ret!=0;
6268 }
6269
6270 //The Dialogue that loads a ZMOD Module File
6271 int32_t zc_load_zmod_module_file()
6272 {
6273 if ( Playing )
6274 {
6275 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6276 return -1;
6277 }
6278 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6279 return D_CLOSE;
6280
6281 FILE *tempmodule = fopen(modulepath,"r");
6282
6283 if(tempmodule == NULL)
6284 {
6285 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6286 return -1;
6287 }
6288
6289
6290 //Set the module path:
6291 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6292 strcpy(moduledata.module_name, modulepath);
6293 al_trace("New Module Path is: %s \n", moduledata.module_name);
6294 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6295 zcm.init(true); //Load the module values.
6296 moduledata.refresh_title_screen = 1;
6297 // refresh_select_screen = 1;
6298 build_biic_list();
6299 return D_O_K;
6300 }
6301
6302 static DIALOG module_info_dlg[] =
6303 {
6304 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6305
6306
6307 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6308 //1
6309 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6310 //2
6311 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6312 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6313 //4
6314 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6315 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6316 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6317 //7
6318
6319 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6320 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6321 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6322 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6323 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6324 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6325 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6326 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6327 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6328
6329 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6330 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6331 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6332 };
6333
6334 void about_zcplayer_module(const char *prompt,int32_t initialval)
6335 {
6336
6337 module_info_dlg[0].dp2 = lfont;
6338 if ( moduledata.moduletitle[0] != 0 )
6339 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6340
6341 if ( moduledata.moduleauthor[0] != 0 )
6342 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6343
6344 if ( moduledata.moduleinfo0[0] != 0 )
6345 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6346 if ( moduledata.moduleinfo1[0] != 0 )
6347 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6348 if ( moduledata.moduleinfo2[0] != 0 )
6349 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6350 if ( moduledata.moduleinfo3[0] != 0 )
6351 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6352 if ( moduledata.moduleinfo4[0] != 0 )
6353 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6354
6355 char module_date[255];
6356 memset(module_date, 0, sizeof(module_date));
6357 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6358 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6359
6360
6361
6362 char module_vers[255];
6363 memset(module_vers, 0, sizeof(module_vers));
6364 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6365
6366
6367 //sprintf(tilecount,"%d",1);
6368
6369 char module_build[255];
6370 memset(module_build, 0, sizeof(module_build));
6371 if ( moduledata.modbeta )
6372 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6373 else
6374 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6375
6376 module_info_dlg[12].dp = (char*)module_date;
6377 module_info_dlg[13].dp = (char*)module_vers;
6378 module_info_dlg[14].dp = (char*)module_build;
6379
6380 if(is_large)
6381 large_dialog(module_info_dlg);
6382
6383 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6384 jwin_center_dialog(module_info_dlg);
6385
6386
6387 }
6388
6389 int32_t onAbout_ZCP_Module()
6390 {
6391 about_zcplayer_module("About Module (.zmod)", 0);
6392 return D_O_K;
6393 }
6394
6395 //New Modules Menu for 2.55+
6396 static MENU zcmodule_menu[] =
6397 {
6398 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6399 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6400
6401 { NULL, NULL, NULL, 0, NULL }
6402 };
6403
6404 int32_t onToggleRecordingNewSaves()
6405 {
6406 if (zc_get_config("zeldadx", "replay_new_saves", false))
6407 {
6408 zc_set_config("zeldadx", "replay_new_saves", false);
6409 }
6410 else
6411 {
6412 zc_set_config("zeldadx", "replay_new_saves", true);
6413 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6414 NULL,NULL,"OK",NULL,13,27,lfont);
6415 }
6416 return D_O_K;
6417 }
6418
6419 int32_t onToggleSnapshotAllFrames()
6420 {
6421 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6422 return D_O_K;
6423 }
6424
6425 int32_t onStopReplayOrRecord()
6426 {
6427 if (replay_is_replaying())
6428 {
6429 replay_quit();
6430 }
6431 else if (replay_get_mode() == ReplayMode::Record)
6432 {
6433 if (!replay_get_meta_bool("test_mode"))
6434 {
6435 jwin_alert("Recording", "You cannot stop recording a save file.",
6436 NULL,NULL,"OK",NULL,13,27,lfont);
6437 return D_CLOSE;
6438 }
6439
6440 if (jwin_alert("Stop Recording",
6441 "Save replay to disk and stop recording?",
6442 "This will stop the recording.",
6443 NULL,
6444 "Yes","No",13,27,lfont) != 1)
6445 return D_CLOSE;
6446
6447 replay_save();
6448 replay_stop();
6449 }
6450 return D_O_K;
6451 }
6452
6453 static int32_t handle_on_load_replay(ReplayMode mode)
6454 {
6455 if (Playing)
6456 {
6457 if (jwin_alert("Replay - Warning!",
6458 "Loading a replay will exit the current game.",
6459 "All unsaved progress will be lost.",
6460 "Do you wish to continue?",
6461 "Yes","No",13,27,lfont) != 1)
6462 return D_CLOSE;
6463 }
6464
6465 std::string mode_string = replay_mode_to_string(mode);
6466 mode_string[0] = std::toupper(mode_string[0]);
6467
6468 std::string line_1 = "Select a replay file to play back.";
6469 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6470 std::string line_3 = "You can stop the replay and take over manually any time.";
6471 if (mode == ReplayMode::Update)
6472 {
6473 line_1 = "Select a replay file to update.";
6474 line_2 = "WARNING: be sure to back up the zplay file";
6475 line_3 = "and verify that the updated replay works as expected!";
6476 }
6477
6478 if (jwin_alert(mode_string.c_str(),
6479 line_1.c_str(),
6480 line_2.c_str(),
6481 line_3.c_str(),
6482 "OK","Nevermind",13,27,lfont) == 1)
6483 {
6484 char replay_path[2048];
6485 strcpy(replay_path, "replays/");
6486 if (jwin_file_select_ex(
6487 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6488 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6489 return D_CLOSE;
6490
6491 replay_quit();
6492 load_replay_file_deferred(mode, replay_path);
6493 Quit = qRESET;
6494 return D_CLOSE;
6495 }
6496 return D_O_K;
6497 }
6498
6499 int32_t onLoadReplay()
6500 {
6501 return handle_on_load_replay(ReplayMode::Replay);
6502 }
6503
6504 int32_t onLoadReplayAssert()
6505 {
6506 return handle_on_load_replay(ReplayMode::Assert);
6507 }
6508
6509 int32_t onLoadReplayUpdate()
6510 {
6511 return handle_on_load_replay(ReplayMode::Update);
6512 }
6513
6514 int32_t onSaveReplay()
6515 {
6516 if (replay_get_mode() == ReplayMode::Record)
6517 {
6518 if (!replay_get_meta_bool("test_mode"))
6519 {
6520 if (jwin_alert("Save Replay",
6521 "This will save a copy of the replay up to this point.",
6522 "The official replay file will be untouched.",
6523 "Do you wish to continue?",
6524 "Yes","No",13,27,lfont) != 1)
6525 return D_CLOSE;
6526
6527 char replay_path[2048];
6528 strcpy(replay_path, replay_get_filename().c_str());
6529 if (jwin_file_select_ex(
6530 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6531 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6532 return D_CLOSE;
6533
6534 if (fileexists(replay_path))
6535 {
6536 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6537 NULL,NULL,"OK",NULL,13,27,lfont);
6538 return D_CLOSE;
6539 }
6540
6541 replay_save(replay_path);
6542 }
6543 else
6544 {
6545 replay_save();
6546 }
6547 }
6548 return D_O_K;
6549 }
6550
6551 static MENU replay_menu[] =
6552 {
6553 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6554 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6555 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6556 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6557 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6558 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6559 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6560
6561 { NULL, NULL, NULL, 0, NULL }
6562 };
6563
6564 static DIALOG credits_dlg[] =
6565 {
6566 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6567 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6568 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6569 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6570 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6571 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6572 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6573 };
6574
6575 14 static ListData dmap_list(dmaplist, &font);
6576
6577 static DIALOG goto_dlg[] =
6578 {
6579 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6580 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6581 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6582 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6583 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6584 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6585 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6586 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6587 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6588 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6589 };
6590
6591 int32_t onGoTo()
6592 {
6593 bool music = false;
6594 music = music;
6595 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6596
6597 goto_dlg[0].dp2=lfont;
6598 goto_dlg[4].d2=cheat_goto_dmap;
6599 goto_dlg[6].dp=cheat_goto_screen_str;
6600
6601 clear_keybuf();
6602
6603 if(is_large)
6604 large_dialog(goto_dlg);
6605
6606 if(zc_popup_dialog(goto_dlg,4)==1)
6607 {
6608 // dmap, screen
6609 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6610 };
6611
6612 return D_O_K;
6613 }
6614
6615 int32_t onGoToComplete()
6616 {
6617 if(!Playing)
6618 {
6619 return D_O_K;
6620 }
6621
6622 system_pal();
6623 music_pause();
6624 pause_all_sfx();
6625 show_mouse(screen);
6626 onGoTo();
6627 eat_buttons();
6628
6629 zc_readrawkey(KEY_ESC);
6630
6631 show_mouse(NULL);
6632 game_pal();
6633 music_resume();
6634 resume_all_sfx();
6635 return D_O_K;
6636 }
6637
6638 int32_t onCredits()
6639 {
6640 go();
6641
6642 BITMAP *win = create_bitmap_ex(8,222,110);
6643
6644 if(!win)
6645 return D_O_K;
6646
6647 int32_t c=0;
6648 int32_t l=0;
6649 int32_t ol=-1;
6650 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6651 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6652 PALETTE tmppal;
6653
6654 rti_gui.transparency_index = 1;
6655
6656 clear_to_color(win, rti_gui.transparency_index);
6657 draw_rle_sprite(win,rle,0,0);
6658 credits_dlg[0].dp2=lfont;
6659 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6660 credits_dlg[2].dp = win;
6661
6662 set_palette_range(black_palette,0,127,false);
6663
6664 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6665
6666 BITMAP* old_screen = screen;
6667 BITMAP* gui_bmp = zc_get_gui_bmp();
6668 ASSERT(gui_bmp);
6669 clear_to_color(gui_bmp, rti_gui.transparency_index);
6670 screen = gui_bmp;
6671
6672 while(update_dialog(p))
6673 {
6674 throttleFPS();
6675 ++c;
6676 l = zc_max((c>>1)-30,0);
6677
6678 if(l > rle->h)
6679 l = c = 0;
6680
6681 if(l > rle->h - 112)
6682 l = rle->h - 112;
6683
6684 clear_bitmap(win);
6685 draw_rle_sprite(win,rle,0,0-l);
6686
6687 if(c<=64)
6688 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6689
6690 set_palette_range(tmppal,0,127,false);
6691
6692 if(l!=ol)
6693 {
6694 scare_mouse();
6695 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6696 unscare_mouse();
6697 SCRFIX();
6698 ol=l;
6699 }
6700
6701 update_hw_screen();
6702 }
6703
6704 screen = old_screen;
6705 system_pal();
6706
6707 shutdown_dialog(p);
6708 destroy_bitmap(win);
6709 //comeback();
6710
6711 rti_gui.transparency_index = 0;
6712
6713 return D_O_K;
6714 }
6715
6716 const char *midilist(int32_t index, int32_t *list_size)
6717 {
6718 if(index<0)
6719 {
6720 *list_size=0;
6721
6722 for(int32_t i=0; i<MAXMIDIS; i++)
6723 if(tunes[i].data)
6724 ++(*list_size);
6725
6726 return NULL;
6727 }
6728
6729 int32_t i=0,m=0;
6730
6731 while(m<=index && i<=MAXMIDIS)
6732 {
6733 if(tunes[i].data)
6734 ++m;
6735
6736 ++i;
6737 }
6738
6739 --i;
6740
6741 if(i==MAXMIDIS && m<index)
6742 return "(null)";
6743
6744 return tunes[i].title;
6745 }
6746
6747 /* ------- MIDI info stuff -------- */
6748
6749 char *text;
6750 midi_info *zmi;
6751 bool dialog_running;
6752 bool listening;
6753
6754 void get_info(int32_t index);
6755
6756 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6757 {
6758 int32_t d2 = d->d2;
6759 int32_t ret = jwin_droplist_proc(msg,d,c);
6760
6761 if(d2!=d->d2)
6762 {
6763 get_info(d->d2);
6764 }
6765
6766 return ret;
6767 }
6768
6769 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6770 {
6771 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6772
6773 int32_t ret = jwin_button_proc(msg,d,c);
6774
6775 if(ret == D_CLOSE)
6776 {
6777 // get current midi index
6778 int32_t index = (d+(d->d1))->d2;
6779 int32_t i=0, m=0;
6780
6781 while(m<=index && i<=MAXMIDIS)
6782 {
6783 if(tunes[i].data)
6784 ++m;
6785
6786 ++i;
6787 }
6788
6789 --i;
6790 jukebox(i);
6791 listening = true;
6792 ret = D_O_K;
6793 }
6794
6795 return ret;
6796 }
6797
6798 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6799 {
6800 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6801
6802 int32_t ret = jwin_button_proc(msg,d,c);
6803
6804 if(ret == D_CLOSE)
6805 {
6806 // get current midi index
6807 int32_t index = (d+(d->d1))->d2;
6808 int32_t i=0, m=0;
6809
6810 while(m<=index && i<=MAXMIDIS)
6811 {
6812 if(tunes[i].data)
6813 ++m;
6814
6815 ++i;
6816 }
6817
6818 --i;
6819
6820 // get file name
6821
6822 int32_t sel=0;
6823 //struct ffblk f;
6824 char title[40] = "Save MIDI: ";
6825 char fname[2048];
6826 memset(fname,0,2048);
6827 static EXT_LIST list[] =
6828 {
6829 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6830 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6831 { NULL, NULL }
6832 };
6833
6834 strcpy(title+11, tunes[i].title);
6835 title[39] = '\0';
6836
6837 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6838 goto done;
6839
6840 if(exists(fname))
6841 {
6842 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6843 goto done;
6844 }
6845
6846 // save midi i
6847
6848 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6849 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6850
6851 done:
6852 chop_path(fname);
6853 ret = D_REDRAW;
6854 }
6855
6856 return ret;
6857 }
6858
6859 14 static ListData midi_list(midilist, &font);
6860
6861 static DIALOG midi_dlg[] =
6862 {
6863 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6864 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6865 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6866 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6867 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6868 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6869 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6870 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6871 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6872 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6873 };
6874
6875 void get_info(int32_t index)
6876 {
6877 int32_t i=0, m=0;
6878
6879 while(m<=index && i<=MAXMIDIS)
6880 {
6881 if(tunes[i].data)
6882 ++m;
6883
6884 ++i;
6885 }
6886
6887 --i;
6888
6889 if(i==MAXMIDIS && m<index)
6890 strcpy(text,"(null)");
6891 else
6892 {
6893 get_midi_info((MIDI*)tunes[i].data,zmi);
6894 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6895 }
6896
6897 midi_dlg[0].dp2=lfont;
6898 midi_dlg[3].dp = text;
6899 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6900 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6901
6902 if(dialog_running)
6903 {
6904 scare_mouse();
6905 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6906 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6907 unscare_mouse();
6908 }
6909 }
6910
6911 int32_t onMIDICredits()
6912 {
6913 text = (char*)malloc(4096);
6914 zmi = (midi_info*)malloc(sizeof(midi_info));
6915
6916 if(!text || !zmi)
6917 {
6918 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6919 return D_O_K;
6920 }
6921
6922 bool do_pause_midi = midi_pos >= 0 && currmidi;
6923 auto restore_midi = currmidi;
6924 if(do_pause_midi)
6925 {
6926 paused_midi_pos = midi_pos;
6927 stop_midi();
6928 midi_paused=true;
6929 midi_suspended = midissuspHALTED;
6930 }
6931
6932 midi_dlg[0].dp2=lfont;
6933 midi_dlg[2].d1 = 0;
6934 midi_dlg[2].d2 = 0;
6935 midi_dlg[4].flags = D_EXIT;
6936 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6937
6938 listening = false;
6939 dialog_running=false;
6940 get_info(0);
6941
6942 dialog_running=true;
6943
6944 if(is_large)
6945 large_dialog(midi_dlg);
6946
6947 zc_popup_dialog(midi_dlg,0);
6948 dialog_running=false;
6949
6950 if(listening)
6951 music_stop();
6952
6953 if(do_pause_midi)
6954 {
6955 midi_suspended = midissuspRESUME;
6956 currmidi = restore_midi;
6957 midi_pos = paused_midi_pos;
6958 }
6959
6960 if(text) free(text);
6961 if(zmi) free(zmi);
6962 return D_O_K;
6963 }
6964
6965 int32_t onAbout()
6966 {
6967 char buf1[80]={0};
6968 std::ostringstream oss;
6969 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6970 oss << buf1 << '\n';
6971 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6972 oss << buf1 << '\n';
6973 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6974 oss << buf1 << '\n';
6975 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6976 oss << buf1 << '\n';
6977
6978 InfoDialog("About ZC", oss.str()).show();
6979 return D_O_K;
6980 }
6981
6982 int32_t onQuest()
6983 {
6984 char fname[100];
6985 strcpy(fname, get_filename(qstpath));
6986 quest_dlg[0].dp2=lfont;
6987 quest_dlg[1].dp = fname;
6988
6989 if(QHeader.quest_number==0)
6990 sprintf(str_a,"Custom");
6991 else
6992 sprintf(str_a,"%d",QHeader.quest_number);
6993
6994 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6995
6996 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6997 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6998
6999 if(is_large)
7000 large_dialog(quest_dlg);
7001
7002 zc_popup_dialog(quest_dlg, 0);
7003 return D_O_K;
7004 }
7005
7006 void call_vidmode_dlg();
7007 int32_t onVidMode()
7008 {
7009 call_vidmode_dlg();
7010 return D_O_K;
7011 }
7012
7013 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7014 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7015 //Added an extra statement, so that if the key is cleared to 0, the cleared
7016 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7017
7018 void load_ukeys(int32_t* arr)
7019 {
7020 arr[ukey_a] = Akey;
7021 arr[ukey_b] = Bkey;
7022 arr[ukey_s] = Skey;
7023 arr[ukey_l] = Lkey;
7024 arr[ukey_r] = Rkey;
7025 arr[ukey_p] = Pkey;
7026 arr[ukey_ex1] = Exkey1;
7027 arr[ukey_ex2] = Exkey2;
7028 arr[ukey_ex3] = Exkey3;
7029 arr[ukey_ex4] = Exkey4;
7030 arr[ukey_du] = DUkey;
7031 arr[ukey_dd] = DDkey;
7032 arr[ukey_dl] = DLkey;
7033 arr[ukey_dr] = DRkey;
7034 arr[ukey_mod1a] = cheat_modifier_keys[0];
7035 arr[ukey_mod1b] = cheat_modifier_keys[1];
7036 arr[ukey_mod2a] = cheat_modifier_keys[2];
7037 arr[ukey_mod2b] = cheat_modifier_keys[3];
7038 };
7039
7040 static const char* ukey_names[] = {
7041 "A", "B", "Start", "L", "R", "Map",
7042 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7043 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7044 "Cheat Mod R1", "Cheat Mod R2",
7045 };
7046 std::string get_ukey_name(int32_t k)
7047 {
7048 if (k < num_ukey) return ukey_names[k];
7049 return "";
7050 }
7051
7052 int32_t onKeyboard()
7053 {
7054 int32_t a = Akey;
7055 int32_t b = Bkey;
7056 int32_t s = Skey;
7057 int32_t l = Lkey;
7058 int32_t r = Rkey;
7059 int32_t p = Pkey;
7060 int32_t ex1 = Exkey1;
7061 int32_t ex2 = Exkey2;
7062 int32_t ex3 = Exkey3;
7063 int32_t ex4 = Exkey4;
7064 int32_t du = DUkey;
7065 int32_t dd = DDkey;
7066 int32_t dl = DLkey;
7067 int32_t dr = DRkey;
7068 int32_t mod1a = cheat_modifier_keys[0];
7069 int32_t mod1b = cheat_modifier_keys[1];
7070 int32_t mod2a = cheat_modifier_keys[2];
7071 int32_t mod2b = cheat_modifier_keys[3];
7072 bool done=false;
7073 int32_t ret;
7074
7075 keyboard_control_dlg[0].dp2=lfont;
7076
7077 if(is_large)
7078 large_dialog(keyboard_control_dlg);
7079
7080 while(!done)
7081 {
7082 ret = zc_popup_dialog(keyboard_control_dlg,3);
7083
7084 if(ret==3) // OK
7085 {
7086 int32_t ukeys[num_ukey];
7087 load_ukeys(ukeys);
7088 std::vector<std::string> uniqueError;
7089 for(int32_t q = 0; q < num_ukey; ++q)
7090 {
7091 for(int32_t p = q+1; p < num_ukey; ++p)
7092 {
7093 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7094 {
7095 char buf[64];
7096 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7097 std::string str(buf);
7098 uniqueError.push_back(str);
7099 }
7100 }
7101 }
7102 if(uniqueError.size() == 0)
7103 {
7104 done = true;
7105 save_control_configs(true);
7106 }
7107 else
7108 {
7109 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7110 box_out("Cannot have duplicate keybinds!"); box_eol();
7111 for(std::vector<std::string>::iterator it = uniqueError.begin();
7112 it != uniqueError.end(); ++it)
7113 {
7114 box_out((*it).c_str()); box_eol();
7115 }
7116 box_end(true);
7117 }
7118 /* Old uniqueness check
7119 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7120 bool unique = true;
7121 addToHash(A,unique,keyhash);
7122 addToHash(B,unique,keyhash);
7123 addToHash(S,unique,keyhash);
7124 addToHash(L,unique,keyhash);
7125 addToHash(R,unique,keyhash);
7126 addToHash(P,unique,keyhash);
7127 addToHash(DU,unique,keyhash);
7128 addToHash(DD,unique,keyhash);
7129 addToHash(DL,unique,keyhash);
7130 addToHash(DR,unique,keyhash);
7131
7132 if(keyhash->find(Exkey1) == keyhash->end())
7133 {
7134 (*keyhash)[Exkey1]=true;
7135 }
7136 else
7137 {
7138 if ( Exkey1 != 0 ) unique = false;
7139 }
7140
7141 if(keyhash->find(Exkey2) == keyhash->end())
7142 {
7143 (*keyhash)[Exkey2]=true;
7144 }
7145 else
7146 {
7147 if ( Exkey2 != 0 ) unique = false;
7148 }
7149
7150 if(keyhash->find(Exkey3) == keyhash->end())
7151 {
7152 (*keyhash)[Exkey3]=true;
7153 }
7154 else
7155 {
7156 if ( Exkey3 != 0 ) unique = false;
7157 }
7158
7159 if(keyhash->find(Exkey4) == keyhash->end())
7160 {
7161 (*keyhash)[Exkey4]=true;
7162 }
7163 else
7164 {
7165 if ( Exkey4 != 0 )unique = false;
7166 }
7167 //modifier keys
7168 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7169 {
7170 (*keyhash)[cheat_modifier_keys[0]]=true;
7171 }
7172 else
7173 {
7174 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7175 }
7176 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7177 {
7178 (*keyhash)[cheat_modifier_keys[1]]=true;
7179 }
7180 else
7181 {
7182 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7183 }
7184 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7185 {
7186 (*keyhash)[cheat_modifier_keys[2]]=true;
7187 }
7188 else
7189 {
7190 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7191 }
7192 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7193 {
7194 (*keyhash)[cheat_modifier_keys[3]]=true;
7195 }
7196 else
7197 {
7198 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7199 }
7200
7201 delete keyhash;
7202
7203 if(unique)
7204 done=true;
7205 else
7206 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7207 */
7208 }
7209 else // Cancel
7210 {
7211 Akey = a;
7212 Bkey = b;
7213 Skey = s;
7214 Lkey = l;
7215 Rkey = r;
7216 Pkey = p;
7217 Exkey1 = ex1;
7218 Exkey2 = ex2;
7219 Exkey3 = ex3;
7220 Exkey4 = ex4;
7221 DUkey = du;
7222 DDkey = dd;
7223 DLkey = dl;
7224 DRkey = dr;
7225 cheat_modifier_keys[0] = mod1a;
7226 cheat_modifier_keys[1] = mod1b;
7227 cheat_modifier_keys[2] = mod2a;
7228 cheat_modifier_keys[3] = mod2b;
7229
7230 done=true;
7231 }
7232
7233 rest(1);
7234 }
7235
7236 return D_O_K;
7237 }
7238
7239 int32_t onGamepad()
7240 {
7241 int32_t a = Abtn;
7242 int32_t b = Bbtn;
7243 int32_t s = Sbtn;
7244 int32_t l = Lbtn;
7245 int32_t r = Rbtn;
7246 int32_t m = Mbtn;
7247 int32_t p = Pbtn;
7248 int32_t ex1 = Exbtn1;
7249 int32_t ex2 = Exbtn2;
7250 int32_t ex3 = Exbtn3;
7251 int32_t ex4 = Exbtn4;
7252 int32_t up = DUbtn;
7253 int32_t down = DDbtn;
7254 int32_t left = DLbtn;
7255 int32_t right = DRbtn;
7256
7257 gamepad_dlg[0].dp2=lfont;
7258 if(analog_movement)
7259 gamepad_dlg[56].flags|=D_SELECTED;
7260 else
7261 gamepad_dlg[56].flags&=~D_SELECTED;
7262
7263 if(is_large)
7264 large_dialog(gamepad_dlg);
7265
7266 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7267
7268 if(ret == 4) //OK
7269 {
7270 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7271 save_control_configs(false);
7272 }
7273 else //Cancel
7274 {
7275 Abtn = a;
7276 Bbtn = b;
7277 Sbtn = s;
7278 Lbtn = l;
7279 Rbtn = r;
7280 Mbtn = m;
7281 Pbtn = p;
7282 Exbtn1 = ex1;
7283 Exbtn2 = ex2;
7284 Exbtn3 = ex3;
7285 Exbtn4 = ex4;
7286 DUbtn = up;
7287 DDbtn = down;
7288 DLbtn = left;
7289 DRbtn = right;
7290 }
7291
7292 return D_O_K;
7293 }
7294
7295 int32_t onSound()
7296 {
7297 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7298 {
7299 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7300 }
7301 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7302 {
7303 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7304 }
7305 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7306 {
7307 emusic_volume = (int32_t)FFCore.usr_music_volume;
7308 }
7309 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7310 {
7311 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7312 }
7313 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7314 {
7315 pan_style = (int32_t)FFCore.usr_panstyle;
7316 }
7317
7318 int32_t m = midi_volume;
7319 int32_t d = digi_volume;
7320 int32_t e = emusic_volume;
7321 int32_t b = zcmusic_bufsz;
7322 int32_t s = sfx_volume;
7323 int32_t p = pan_style;
7324 pan_style = vbound(pan_style,0,3);
7325
7326 sound_dlg[0].dp2=lfont;
7327
7328 if(is_large)
7329 large_dialog(sound_dlg);
7330
7331 midi_dp[1] = sound_dlg[6].x;
7332 midi_dp[2] = sound_dlg[6].y;
7333 digi_dp[1] = sound_dlg[7].x;
7334 digi_dp[2] = sound_dlg[7].y;
7335 emus_dp[1] = sound_dlg[8].x;
7336 emus_dp[2] = sound_dlg[8].y;
7337 buf_dp[1] = sound_dlg[9].x;
7338 buf_dp[2] = sound_dlg[9].y;
7339 sfx_dp[1] = sound_dlg[10].x;
7340 sfx_dp[2] = sound_dlg[10].y;
7341 pan_dp[1] = sound_dlg[11].x;
7342 pan_dp[2] = sound_dlg[11].y;
7343 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7344 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7345 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7346 sound_dlg[18].d2 = zcmusic_bufsz;
7347 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7348 sound_dlg[20].d2 = pan_style;
7349
7350 int32_t ret = zc_popup_dialog(sound_dlg,1);
7351
7352 if(ret==2)
7353 {
7354 master_volume(digi_volume,midi_volume);
7355
7356 for(int32_t i=0; i<WAV_COUNT; ++i)
7357 {
7358 //allegro assertion fails when passing in -1 as voice -DD
7359 if(sfx_voice[i] > 0)
7360 voice_set_volume(sfx_voice[i], sfx_volume);
7361 }
7362 zc_set_config(sfx_sect,"digi",digi_volume);
7363 zc_set_config(sfx_sect,"midi",midi_volume);
7364 zc_set_config(sfx_sect,"sfx",sfx_volume);
7365 zc_set_config(sfx_sect,"emusic",emusic_volume);
7366 zc_set_config(sfx_sect,"pan",pan_style);
7367 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7368 }
7369 else
7370 {
7371 midi_volume = m;
7372 digi_volume = d;
7373 emusic_volume = e;
7374 zcmusic_bufsz = b;
7375 sfx_volume = s;
7376 pan_style = p;
7377 }
7378
7379 return D_O_K;
7380 }
7381
7382 int32_t queding(char const* s1, char const* s2, char const* s3)
7383 {
7384 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7385 }
7386
7387 int32_t onQuit()
7388 {
7389 if(Playing)
7390 {
7391 int32_t ret=0;
7392
7393 if(get_bit(quest_rules, qr_NOCONTINUE))
7394 {
7395 if(standalone_mode)
7396 {
7397 ret=queding("End current game?",
7398 "The continue screen is disabled; the game",
7399 "will be reloaded from the last save.");
7400 }
7401 else
7402 {
7403 ret=queding("End current game?",
7404 "The continue screen is disabled. You will",
7405 "be returned to the file select screen.");
7406 }
7407 }
7408 else
7409 ret=queding("End current game?",NULL,NULL);
7410
7411 if(ret==1)
7412 {
7413 disableClickToFreeze=false;
7414 Quit=qQUIT;
7415
7416 // Trying to evade a door repair charge?
7417 if(repaircharge)
7418 {
7419 game->change_drupy(-repaircharge);
7420 repaircharge=0;
7421 }
7422
7423 return D_CLOSE;
7424 }
7425 }
7426
7427 return D_O_K;
7428 }
7429
7430 int32_t onTryQuitMenu()
7431 {
7432 return onTryQuit(true);
7433 }
7434
7435 int32_t onTryQuit(bool inMenu)
7436 {
7437 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7438 {
7439 if(get_bit(quest_rules,qr_OLD_F6))
7440 {
7441 if(inMenu) onQuit();
7442 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7443 }
7444 else
7445 {
7446 disableClickToFreeze=false;
7447 GameFlags |= GAMEFLAG_TRYQUIT;
7448 }
7449 return D_CLOSE;
7450 }
7451
7452 return D_O_K;
7453 }
7454
7455 int32_t onReset()
7456 {
7457 if(queding(" Reset system? ",NULL,NULL)==1)
7458 {
7459 disableClickToFreeze=false;
7460 Quit=qRESET;
7461 replay_quit();
7462 return D_CLOSE;
7463 }
7464
7465 return D_O_K;
7466 }
7467
7468 int32_t onExit()
7469 {
7470 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7471 {
7472 Quit=qEXIT;
7473 return D_CLOSE;
7474 }
7475
7476 return D_O_K;
7477 }
7478
7479 int32_t onTitle_NES()
7480 {
7481 title_version=0;
7482 zc_set_config(cfg_sect,"title",title_version);
7483 return D_O_K;
7484 }
7485 int32_t onTitle_DX()
7486 {
7487 title_version=1;
7488 zc_set_config(cfg_sect,"title",title_version);
7489 return D_O_K;
7490 }
7491 int32_t onTitle_25()
7492 {
7493 title_version=2;
7494 zc_set_config(cfg_sect,"title",title_version);
7495 return D_O_K;
7496 }
7497
7498 int32_t onDebug()
7499 {
7500 if(debug_enabled)
7501 set_debug(!get_debug());
7502 return D_O_K;
7503 }
7504
7505 int32_t onHeartBeep()
7506 {
7507 heart_beep=!heart_beep;
7508 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7509 return D_O_K;
7510 }
7511
7512 int32_t onSaveIndicator()
7513 {
7514 use_save_indicator=!use_save_indicator;
7515 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7516 return D_O_K;
7517 }
7518
7519 int32_t onEpilepsy()
7520 {
7521 if(jwin_alert3(
7522 "Epilepsy Flash Reduction",
7523 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7524 "Disabling this will restore standard flash and wavy behaviour.",
7525 "Proceed?",
7526 "&Yes",
7527 "&No",
7528 NULL,
7529 'y',
7530 'n',
7531 0,
7532 lfont) == 1)
7533 {
7534 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7535 zc_set_config("zeldadx","checked_epilepsy",1);
7536 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7537 }
7538 return D_O_K;
7539 }
7540
7541 int32_t onTriforce()
7542 {
7543 for(int32_t i=0; i<MAXINITTABS; ++i)
7544 {
7545 init_tabs[i].flags&=~D_SELECTED;
7546 }
7547
7548 init_tabs[3].flags=D_SELECTED;
7549 return onCheatConsole();
7550 /*triforce_dlg[0].dp2=lfont;
7551 for(int32_t i=1; i<=8; i++)
7552 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7553
7554 if(zc_popup_dialog (triforce_dlg,-1)==9)
7555 {
7556 for(int32_t i=1; i<=8; i++)
7557 {
7558 game->lvlitems[i] &= ~liTRIFORCE;
7559 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7560 }
7561 }
7562 return D_O_K;*/
7563 }
7564
7565 bool rc = false;
7566 /*
7567 int32_t onEquipment()
7568 {
7569 for (int32_t i=0; i<MAXINITTABS; ++i)
7570 {
7571 init_tabs[i].flags&=~D_SELECTED;
7572 }
7573 init_tabs[0].flags=D_SELECTED;
7574 return onCheatConsole();
7575 }
7576 */
7577
7578 int32_t onItems()
7579 {
7580 for(int32_t i=0; i<MAXINITTABS; ++i)
7581 {
7582 init_tabs[i].flags&=~D_SELECTED;
7583 }
7584
7585 init_tabs[1].flags=D_SELECTED;
7586 return onCheatConsole();
7587 }
7588
7589 static DIALOG getnum_dlg[] =
7590 {
7591 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7592 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7593 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7594 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7595 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7596 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7597 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7598 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7599 };
7600
7601 int32_t getnumber(const char *prompt,int32_t initialval)
7602 {
7603 char buf[20];
7604 sprintf(buf,"%d",initialval);
7605 getnum_dlg[0].dp=(void *)prompt;
7606 getnum_dlg[0].dp2=lfont;
7607 getnum_dlg[2].dp=buf;
7608
7609 if(is_large)
7610 large_dialog(getnum_dlg);
7611
7612 if(zc_popup_dialog(getnum_dlg,2)==3)
7613 return atoi(buf);
7614
7615 return initialval;
7616 }
7617
7618 int32_t onLife()
7619 {
7620 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7621 cheats_enqueue(Cheat::Life, value);
7622 return D_O_K;
7623 }
7624
7625 int32_t onHeartC()
7626 {
7627 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7628 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7629 cheats_enqueue(Cheat::MaxLife, max_life);
7630 cheats_enqueue(Cheat::Life, life);
7631 return D_O_K;
7632 }
7633
7634 int32_t onMagicC()
7635 {
7636 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7637 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7638 cheats_enqueue(Cheat::MaxMagic, max_magic);
7639 cheats_enqueue(Cheat::Magic, magic);
7640 return D_O_K;
7641 }
7642
7643 int32_t onRupies()
7644 {
7645 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7646 cheats_enqueue(Cheat::Rupies, value);
7647 return D_O_K;
7648 }
7649
7650 int32_t onMaxBombs()
7651 {
7652 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7653 cheats_enqueue(Cheat::MaxBombs, value);
7654 cheats_enqueue(Cheat::Bombs, value);
7655 return D_O_K;
7656 }
7657
7658 int32_t onRefillLife()
7659 {
7660 cheats_enqueue(Cheat::Life, game->get_maxlife());
7661 return D_O_K;
7662 }
7663 int32_t onRefillMagic()
7664 {
7665 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7666 return D_O_K;
7667 }
7668 int32_t onClock()
7669 {
7670 cheats_enqueue(Cheat::Clock);
7671 return D_O_K;
7672 }
7673
7674 int32_t onQstPath()
7675 {
7676 char path[2048];
7677
7678 chop_path(qstdir);
7679 strcpy(path,qstdir);
7680
7681 go();
7682
7683 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7684 {
7685 chop_path(path);
7686 fix_filename_case(path);
7687 fix_filename_slashes(path);
7688 strcpy(qstdir,path);
7689 strcpy(qstpath,qstdir);
7690 }
7691
7692 comeback();
7693 return D_O_K;
7694 }
7695
7696 #include "dialog/cheat_dialog.h"
7697 int32_t onCheat()
7698 {
7699 call_setcheat_dialog();
7700 game->set_cheat(maxcheat);
7701 if(cheat) game->did_cheat(true);
7702 return D_O_K;
7703 }
7704
7705 int32_t onCheatRupies()
7706 {
7707 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7708 return D_O_K;
7709 }
7710
7711 int32_t onCheatArrows()
7712 {
7713 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7714 return D_O_K;
7715 }
7716
7717 int32_t onCheatBombs()
7718 {
7719 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7720 return D_O_K;
7721 }
7722
7723 // *** screen saver
7724
7725 3587339 int32_t after_time()
7726 {
7727
1/2
✓ Branch 0 taken 3587339 times.
✗ Branch 1 not taken.
3587339 if(ss_enable == 0)
7728 return INT_MAX;
7729
7730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
3587339 if(ss_after <= 0)
7731 return 5 * 60;
7732
7733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
3587339 if(ss_after <= 3)
7734 return ss_after * 15 * 60;
7735
7736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3587339 times.
3587339 if(ss_after <= 13)
7737 return (ss_after - 3) * 60 * 60;
7738
7739 3587339 return MAX_IDLE + 1;
7740 3587339 }
7741
7742 static const char *after_str[15] =
7743 {
7744 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7745 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7746 "Never"
7747 };
7748
7749 const char *after_list(int32_t index, int32_t *list_size)
7750 {
7751 if(index < 0)
7752 {
7753 *list_size = 15;
7754 return NULL;
7755 }
7756
7757 return after_str[index];
7758 }
7759
7760 14 static ListData after__list(after_list, &font);
7761
7762 static DIALOG scrsaver_dlg[] =
7763 {
7764 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7765 14 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7766 14 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7767 14 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7768 14 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7769 14 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7770 14 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7771 14 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7772 14 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7773 14 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7774 14 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7775 14 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7776 14 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7777 14 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7778 };
7779
7780 int32_t onScreenSaver()
7781 {
7782 scrsaver_dlg[0].dp2=lfont;
7783 int32_t oldcfgs[3];
7784 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7785 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7786 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7787
7788 if(is_large)
7789 large_dialog(scrsaver_dlg);
7790
7791 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7792
7793 if(ret == 8 || ret == 9)
7794 {
7795 ss_after = scrsaver_dlg[5].d1;
7796 ss_speed = scrsaver_dlg[6].d2;
7797 ss_density = scrsaver_dlg[7].d2;
7798 if(oldcfgs[0] != ss_after)
7799 zc_set_config(cfg_sect,"ss_after",ss_after);
7800 if(oldcfgs[1] != ss_speed)
7801 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7802 if(oldcfgs[2] != ss_density)
7803 zc_set_config(cfg_sect,"ss_density",ss_density);
7804 }
7805
7806 if(ret == 9)
7807 // preview Screen Saver
7808 {
7809 clear_keybuf();
7810 scare_mouse();
7811 Matrix(ss_speed, ss_density, 30);
7812 system_pal();
7813 unscare_mouse();
7814 }
7815
7816 return D_O_K;
7817 }
7818
7819 /***** Menus *****/
7820
7821 static MENU game_menu[] =
7822 {
7823 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7824 { (char *)"", NULL, NULL, 0, NULL },
7825 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7826 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7827 { (char *)"", NULL, NULL, 0, NULL },
7828 #ifdef __EMSCRIPTEN__
7829 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7830 #elif defined(ALLEGRO_MACOSX)
7831 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7832 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7833 #else
7834 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7835 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7836 #endif
7837 { NULL, NULL, NULL, 0, NULL }
7838 };
7839
7840 static MENU title_menu[] =
7841 {
7842 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7843 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7844 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7845 { NULL, NULL, NULL, 0, NULL }
7846 };
7847
7848 static MENU snapshot_format_menu[] =
7849 {
7850 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7851 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7852 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7853 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7854 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7855 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7856 { NULL, NULL, NULL, 0, NULL }
7857 };
7858
7859 static MENU controls_menu[] =
7860 {
7861 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7862 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7863 { NULL, NULL, NULL, 0, NULL }
7864 };
7865
7866 static MENU name_entry_mode_menu[] =
7867 {
7868 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7869 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7870 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7871 { NULL, NULL, NULL, 0, NULL }
7872 };
7873
7874 static void set_controls_menu_active()
7875 {
7876
7877 }
7878
7879 static MENU settings_menu[] =
7880 {
7881 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7882 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7883 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7884 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7885 { (char *)"", NULL, NULL, 0, NULL },
7886 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7887 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7888 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7889 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7890 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7891 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7892 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7893 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7894 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7895 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7896 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7897 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7898 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7899 { (char *)"", NULL, NULL, 0, NULL },
7900 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7901 { (char *)"", NULL, NULL, 0, NULL },
7902 { NULL, NULL, NULL, 0, NULL }
7903 };
7904
7905
7906 static MENU misc_menu[] =
7907 {
7908 { (char *)"&About...", onAbout, NULL, 0, NULL },
7909 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7910 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7911 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7912 { (char *)"", NULL, NULL, 0, NULL },
7913 //5
7914 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7915 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7916 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7917 { (char *)"", NULL, NULL, 0, NULL },
7918 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7919 //10
7920 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7921 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7922 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7923 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7924 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7925 //15
7926 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7927 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7928 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7929
7930 { NULL, NULL, NULL, 0, NULL }
7931 };
7932
7933 static MENU refill_menu[] =
7934 {
7935 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7936 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7937 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7938 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7939 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7940 { NULL, NULL, NULL, 0, NULL }
7941 };
7942
7943 static MENU show_menu[] =
7944 {
7945 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7946 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7947 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7948 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7949 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7950 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7951 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7952 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7953 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7954 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7955 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7956 { (char *)"", NULL, NULL, 0, NULL },
7957 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7958 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7959 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7960 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7961 { NULL, NULL, NULL, 0, NULL }
7962 };
7963
7964 static MENU cheat_menu[] =
7965 {
7966 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7967 { (char *)"", NULL, NULL, 0, NULL },
7968 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7969 { (char *)"", NULL, NULL, 0, NULL },
7970 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7971 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7972 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7973 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7974 { (char *)"", NULL, NULL, 0, NULL },
7975 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7976 { (char *)"", NULL, NULL, 0, NULL },
7977 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7978 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7979 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7980 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7981 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7982 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7983 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7984 { NULL, NULL, NULL, 0, NULL }
7985 };
7986
7987 static MENU fixes_menu[] =
7988 {
7989 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7990 { NULL, NULL, NULL, 0, NULL }
7991 };
7992
7993 #if DEVLEVEL > 0
7994 int32_t devLogging();
7995 int32_t devDebug();
7996 int32_t devTimestmp();
7997 #if DEVLEVEL > 1
7998 int32_t setCheat();
7999 #endif //DEVLEVEL > 1
8000 enum
8001 {
8002 dv_log,
8003 // dv_dbg,
8004 dv_tmpstmp,
8005 #if DEVLEVEL > 1
8006 dv_nil,
8007 dv_setcheat,
8008 #endif //DEVLEVEL > 1
8009 dv_max
8010 };
8011 static MENU dev_menu[] =
8012 {
8013 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
8014 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
8015 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
8016 #if DEVLEVEL > 1
8017 { (char *)"", NULL, NULL, 0, NULL },
8018 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8019 #endif //DEVLEVEL > 1
8020 { NULL, NULL, NULL, 0, NULL }
8021 };
8022 int32_t devLogging()
8023 {
8024 dev_logging = !dev_logging;
8025 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8026 return D_O_K;
8027 }
8028 // int32_t devDebug()
8029 // {
8030 // dev_debug = !dev_debug;
8031 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8032 // return D_O_K;
8033 // }
8034 int32_t devTimestmp()
8035 {
8036 dev_timestmp = !dev_timestmp;
8037 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8038 return D_O_K;
8039 }
8040 #if DEVLEVEL > 1
8041 int32_t setCheat()
8042 {
8043 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8044 return D_O_K;
8045 }
8046 #endif //DEVLEVEL > 1
8047 #endif //DEVLEVEL > 0
8048
8049 MENU the_player_menu[] =
8050 {
8051 { (char *)"&Game", NULL, game_menu, 0, NULL },
8052 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8053 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8054 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8055 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8056 #if DEVLEVEL > 0
8057 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8058 #endif
8059 { NULL, NULL, NULL, 0, NULL }
8060 };
8061
8062 MENU the_player_menu2[] =
8063 {
8064 { (char *)"&Game", NULL, game_menu, 0, NULL },
8065 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8066 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8067 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8068 #if DEVLEVEL > 0
8069 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8070 #endif
8071 { NULL, NULL, NULL, 0, NULL }
8072 };
8073
8074 int32_t onMIDIPatch()
8075 {
8076 if(jwin_alert3(
8077 "Toggle Windows MIDI Fix",
8078 "This action will change whether ZC Player auto-restarts a MIDI at its",
8079 "last index if you move ZC Player out of focus, then back into focus.",
8080 "Proceed?",
8081 "&Yes",
8082 "&No",
8083 NULL,
8084 'y',
8085 'n',
8086 0,
8087 lfont) == 1)
8088 {
8089 midi_patch_fix = midi_patch_fix ? 0 : 1;
8090 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8091 }
8092 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8093 return D_O_K;
8094 }
8095
8096 int32_t onKeyboardEntry()
8097 {
8098 NameEntryMode=0;
8099 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8100 return D_O_K;
8101 }
8102
8103 int32_t onLetterGridEntry()
8104 {
8105 NameEntryMode=1;
8106 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8107 return D_O_K;
8108 }
8109
8110 int32_t onExtLetterGridEntry()
8111 {
8112 NameEntryMode=2;
8113 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8114 return D_O_K;
8115 }
8116
8117 static BITMAP* oldscreen;
8118 int32_t onFullscreenMenu()
8119 {
8120 // super hacks
8121 screen = oldscreen;
8122 if (onFullscreen() == D_REDRAW)
8123 {
8124 oldscreen = screen;
8125 }
8126 screen = menu_bmp;
8127 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8128 return D_O_K;
8129 }
8130
8131 14 void fix_menu()
8132 {
8133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!debug_enabled)
8134 14 settings_menu[18].text = NULL;
8135 14 }
8136
8137 static DIALOG system_dlg[] =
8138 {
8139 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8140 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8141 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8142 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8143 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8144 #ifndef ALLEGRO_MACOSX
8145 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8146 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8147 #else
8148 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8149 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8150 #endif
8151 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8152 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8153 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8154 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8155 };
8156
8157 static DIALOG system_dlg2[] =
8158 {
8159 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8160 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8161 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8162 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8164 #ifndef ALLEGRO_MACOSX
8165 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8166 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8167 #else
8168 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8169 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8170 #endif
8171 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8172 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8173 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8174 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8175 };
8176
8177 void reset_snapshot_format_menu()
8178 {
8179 for(int32_t i=0; i<ssfmtMAX; ++i)
8180 {
8181 snapshot_format_menu[i].flags=0;
8182 }
8183 }
8184
8185 int32_t onSetSnapshotFormat()
8186 {
8187 switch(active_menu->text[1])
8188 {
8189 case 'B': //"&BMP"
8190 SnapshotFormat=0;
8191 break;
8192
8193 case 'G': //"&GIF"
8194 SnapshotFormat=1;
8195 break;
8196
8197 case 'J': //"&JPG"
8198 SnapshotFormat=2;
8199 break;
8200
8201 case 'P': //"&PNG"
8202 SnapshotFormat=3;
8203 break;
8204
8205 case 'C': //"PC&X"
8206 SnapshotFormat=4;
8207 break;
8208
8209 case 'T': //"&TGA"
8210 SnapshotFormat=5;
8211 break;
8212
8213 case 'L': //"&LBM"
8214 SnapshotFormat=6;
8215 break;
8216 }
8217 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8218
8219 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8220 return D_O_K;
8221 }
8222
8223
8224 28 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8225 {
8226 PALETTE tmp;
8227
8228
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 28 times.
7196 for(int32_t i=0; i<256; i++)
8229 {
8230 7168 tmp[i].r=r;
8231 7168 tmp[i].g=g;
8232 7168 tmp[i].b=b;
8233 7168 }
8234
8235 28 fade_interpolate(src,tmp,dest,pos,from,to);
8236 28 }
8237
8238 28 void system_pal()
8239 {
8240 28 is_sys_pal = true;
8241 static PALETTE pal;
8242 28 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8243
8244 // set up the grayscale palette
8245
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 28 times.
1820 for(int32_t i=128; i<192; i++)
8246 {
8247 1792 pal[i].r = i-128;
8248 1792 pal[i].g = i-128;
8249 1792 pal[i].b = i-128;
8250 1792 }
8251 28 load_colorset(gui_colorset, pal);
8252
8253 28 color_layer(pal, pal, 24,16,16, 28, 128,191);
8254
8255
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 28 times.
3612 for(int32_t i=0; i<256; i+=2)
8256 {
8257 3584 int32_t v = (i>>3)+2;
8258 3584 int32_t c = (i>>3)+192;
8259 3584 pal[c] = _RGB(v,v,v+(v>>1));
8260 /*
8261 if(i<240)
8262 {
8263 _allegro_hline(tmp_scr,0,i,319,c);
8264 _allegro_hline(tmp_scr,0,i+1,319,c);
8265 }
8266 */
8267 3584 }
8268
8269 // draw the vertical screen gradient
8270
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 28 times.
6748 for(int32_t i=0; i<240; ++i)
8271 {
8272 6720 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8273 6720 }
8274
8275 /*
8276 palrstart= 10*63/255; palrend=166*63/255;
8277 palgstart= 36*63/255; palgend=202*63/255;
8278 palbstart=106*63/255; palbend=240*63/255;
8279 paldivs=32;
8280 for(int32_t i=0; i<paldivs; i++)
8281 {
8282 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8283 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8284 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8285 }
8286 */
8287 28 BITMAP *panorama = create_bitmap_ex(8,256,224);
8288 int32_t ts_height, ts_start;
8289
8290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8291 {
8292 clear_to_color(panorama,0);
8293 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8294 ts_height=224-passive_subscreen_height;
8295 ts_start=28;
8296 }
8297 else
8298 {
8299 28 blit(framebuf,panorama,0,0,0,0,256,224);
8300 28 ts_height=224;
8301 28 ts_start=0;
8302 }
8303
8304 // gray scale the current frame
8305
2/2
✓ Branch 0 taken 6272 times.
✓ Branch 1 taken 28 times.
6300 for(int32_t y=0; y<ts_height; y++)
8306 {
8307
2/2
✓ Branch 0 taken 1605632 times.
✓ Branch 1 taken 6272 times.
1611904 for(int32_t x=0; x<256; x++)
8308 {
8309 1605632 int32_t c = panorama->line[y+ts_start][x];
8310
2/2
✓ Branch 0 taken 1599742 times.
✓ Branch 1 taken 5890 times.
1605632 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8311 1605632 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8312 1605632 }
8313 6272 }
8314
8315 28 destroy_bitmap(panorama);
8316
8317 // display everything
8318 28 vsync();
8319 28 hw_palette = &pal;
8320 28 update_hw_pal = true;
8321
8322 // sys_pal = pal;
8323 28 memcpy(sys_pal,pal,sizeof(pal));
8324 28 }
8325
8326 void system_pal2()
8327 {
8328 is_sys_pal = true;
8329 static PALETTE RAMpal2;
8330 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8331
8332 /* Windows 2000 colors
8333 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8334 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8335 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8336 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8337 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8338 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8339 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8340 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8341
8342 byte palrstart= 10*63/255, palrend=166*63/255,
8343 palgstart= 36*63/255, palgend=202*63/255,
8344 palbstart=106*63/255, palbend=240*63/255,
8345 paldivs=7;
8346 for(int32_t i=0; i<paldivs; i++)
8347 {
8348 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8349 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8350 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8351 }
8352 */
8353
8354 /* Windows 98 colors
8355 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8356 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8357 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8358 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8359 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8360 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8361 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8362 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8363
8364 byte palrstart= 0*63/255, palrend=166*63/255,
8365 palgstart= 0*63/255, palgend=202*63/255,
8366 palbstart=128*63/255, palbend=240*63/255,
8367 paldivs=7;
8368 for(int32_t i=0; i<paldivs; i++)
8369 {
8370 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8371 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8372 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8373 }
8374 */
8375
8376 /* Windows 99 colors
8377 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8378 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8379 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8380 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8381 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8382 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8383 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8384 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8385 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8386
8387 byte palrstart= 0*63/255, palrend=166*63/255,
8388 palgstart= 0*63/255, palgend=202*63/255,
8389
8390 palbstart=128*63/255, palbend=240*63/255,
8391 paldivs=6;
8392 for(int32_t i=0; i<paldivs; i++)
8393 {
8394 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8395 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8396 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8397 }
8398 */
8399
8400
8401
8402 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8403 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8404 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8405 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8406 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8407 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8408 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8409 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8410 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8411
8412 byte palrstart= 0*63/255, palrend=166*63/255,
8413 palgstart= 0*63/255, palgend=202*63/255,
8414 palbstart=128*63/255, palbend=240*63/255,
8415 paldivs=6;
8416
8417 for(int32_t i=0; i<paldivs; i++)
8418 {
8419 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8420 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8421 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8422 }
8423
8424 gui_bg_color=jwin_pal[jcBOX];
8425 gui_fg_color=jwin_pal[jcBOXFG];
8426
8427 jwin_set_colors(jwin_pal);
8428
8429
8430 // set up the new palette
8431 for(int32_t i=128; i<192; i++)
8432 {
8433 RAMpal2[i].r = i-128;
8434 RAMpal2[i].g = i-128;
8435 RAMpal2[i].b = i-128;
8436 }
8437
8438 /*
8439 for(int32_t i=0; i<64; i++)
8440 {
8441 RAMpal2[128+i] = _RGB(i,i,i)1));
8442 }
8443 */
8444
8445 /*
8446
8447 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8448 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8449 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8450 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8451 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8452 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8453 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8454
8455 gui_fg_color=vc(14);
8456 gui_bg_color=vc(1);
8457
8458 jwin_set_colors(jwin_pal);
8459 */
8460
8461 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8462
8463 // set up the colors for the vertical screen gradient
8464 for(int32_t i=0; i<256; i+=2)
8465 {
8466 int32_t v = (i>>3)+2;
8467 int32_t c = (i>>3)+192;
8468 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8469
8470 /*
8471 if(i<240)
8472 {
8473 _allegro_hline(tmp_scr,0,i,319,c);
8474 _allegro_hline(tmp_scr,0,i+1,319,c);
8475 }
8476 */
8477 }
8478
8479 // hw_palette = &RAMpal;
8480 // update_hw_pal = true;
8481
8482 for(int32_t i=0; i<240; ++i)
8483 {
8484 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8485 }
8486
8487 /*
8488 byte palrstart= 10*63/255, palrend=166*63/255,
8489 palgstart= 36*63/255, palgend=202*63/255,
8490 palbstart=106*63/255, palbend=240*63/255,
8491 paldivs=32;
8492 for(int32_t i=0; i<paldivs; i++)
8493 {
8494 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8495 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8496 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8497 }
8498 */
8499 BITMAP *panorama = create_bitmap_ex(8,256,224);
8500 int32_t ts_height, ts_start;
8501
8502 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8503 {
8504 clear_to_color(panorama,0);
8505 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8506 ts_height=224-passive_subscreen_height;
8507 ts_start=28;
8508 }
8509 else
8510 {
8511 blit(framebuf,panorama,0,0,0,0,256,224);
8512 ts_height=224;
8513 ts_start=0;
8514 }
8515
8516 // gray scale the current frame
8517 for(int32_t y=0; y<ts_height; y++)
8518 {
8519 for(int32_t x=0; x<256; x++)
8520 {
8521 int32_t c = panorama->line[y+ts_start][x];
8522 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8523 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8524 }
8525 }
8526
8527 destroy_bitmap(panorama);
8528
8529 // display everything
8530 vsync();
8531 hw_palette = &RAMpal2;
8532 update_hw_pal = true;
8533
8534 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8535
8536 // sys_pal = pal;
8537 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8538 }
8539
8540 static uint32_t entered_sys_pal = 0;
8541 14 void enter_sys_pal()
8542 {
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8544 {
8545 if(entered_sys_pal)
8546 ++entered_sys_pal;
8547 return;
8548 }
8549 14 system_pal();
8550 14 ++entered_sys_pal;
8551 14 }
8552 14 void exit_sys_pal()
8553 {
8554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8555 {
8556
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8557 {
8558 14 game_pal();
8559 14 }
8560 14 }
8561 14 }
8562
8563 void switch_out_callback()
8564 {
8565 if (pause_in_background)
8566 {
8567 callback_switchin = 3;
8568 return;
8569 }
8570
8571 #ifdef _WIN32
8572 if(midi_patch_fix==0 || currmidi==-1)
8573 return;
8574
8575
8576 paused_midi_pos = midi_pos;
8577 zc_stop_midi();
8578 midi_paused=true;
8579 midi_suspended = midissuspHALTED;
8580 #endif
8581 }
8582
8583 void switch_in_callback()
8584 {
8585 if(pause_in_background)
8586 {
8587 return;
8588 }
8589
8590 #ifdef _WIN32
8591 if(midi_patch_fix==0 || currmidi==-1)
8592 return;
8593
8594 else
8595 {
8596 callback_switchin = 1;
8597 midi_suspended = midissuspRESUME;
8598 }
8599 #endif
8600 }
8601
8602 143 void game_pal()
8603 {
8604 143 is_sys_pal = false;
8605 143 entered_sys_pal = 0;
8606 143 clear_to_color(screen,BLACK);
8607 143 hw_palette = &RAMpal;
8608 143 update_hw_pal = true;
8609 143 }
8610
8611 static char bar_str[] = "";
8612
8613 14 void music_pause()
8614 {
8615 //al_pause_duh(tmplayer);
8616 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8617 14 zc_midi_pause();
8618 14 midi_paused=true;
8619 14 }
8620
8621 void music_resume()
8622 {
8623 //al_resume_duh(tmplayer);
8624 zcmusic_pause(zcmusic, ZCM_RESUME);
8625 zc_midi_resume();
8626 midi_paused=false;
8627 }
8628
8629 2632 void music_stop()
8630 {
8631 //al_stop_duh(tmplayer);
8632 //unload_duh(tmusic);
8633 //tmusic=NULL;
8634 //tmplayer=NULL;
8635 2632 zcmusic_stop(zcmusic);
8636 2632 zcmusic_unload_file(zcmusic);
8637 2632 zc_stop_midi();
8638 2632 midi_paused=false;
8639 2632 currmidi=-1;
8640 2632 }
8641
8642 void System()
8643 {
8644 mouse_down=gui_mouse_b();
8645 music_pause();
8646 pause_all_sfx();
8647 MenuOpen = true;
8648 system_pal();
8649 // FONT *oldfont=font;
8650 // font=tfont;
8651
8652 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8653 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8654
8655 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8656 #if DEVLEVEL > 1
8657 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8658 #endif
8659 game_menu[3].flags =
8660 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8661 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8662 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8663 clear_keybuf();
8664 show_mouse(screen);
8665
8666 DIALOG_PLAYER *p;
8667
8668 clear_bitmap(menu_bmp);
8669 oldscreen = screen;
8670 screen = menu_bmp;
8671
8672 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8673 {
8674 p = init_dialog(system_dlg2,-1);
8675 }
8676 else
8677 {
8678 p = init_dialog(system_dlg,-1);
8679 }
8680
8681 // drop the menu on startup if menu button pressed
8682 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8683 simulate_keypress(KEY_G << 8);
8684
8685 do
8686 {
8687 if(close_button_quit)
8688 {
8689 close_button_quit = false;
8690 f_Quit(qEXIT);
8691 if(Quit) break;
8692 }
8693 rest(17);
8694
8695 if(mouse_down && !gui_mouse_b())
8696 mouse_down=0;
8697
8698 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8699 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8700 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8701
8702 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8703 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8704 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8705 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8706 settings_menu[8].flags = NESquit?D_SELECTED:0;
8707 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8708 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8709 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8710 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8711 settings_menu[13].flags = volkeys?D_SELECTED:0;
8712 //Epilepsy Prevention
8713 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8714
8715 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8716 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8717 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8718
8719 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8720 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8721 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8722
8723 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8724 cheat_menu[0].flags = 0;
8725 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8726 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8727 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8728 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8729 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8730 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8731 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8732 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8733 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8734
8735 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8736 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8737 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8738 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8739 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8740 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8741 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8742 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8743 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8744 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8745 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8746 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8747 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8748 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8749 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8750
8751 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8752 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8753
8754 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8755 (char *)"Disable recording new saves" :
8756 (char *)"Enable recording new saves";
8757 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8758 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8759 (char *)"Stop recording" :
8760 (char *)"Stop replaying";
8761 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8762 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8763 (char *)"Disable snapshot all frames" :
8764 (char *)"Enable snapshot all frames";
8765
8766 reset_snapshot_format_menu();
8767 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8768
8769 if(debug_enabled)
8770 {
8771 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8772 }
8773
8774 if(gui_mouse_b() && !mouse_down)
8775 break;
8776
8777 // press menu to drop the menu
8778 if(rMbtn())
8779 simulate_keypress(KEY_G << 8);
8780
8781 if(input_idle(true) > after_time())
8782 // run Screeen Saver
8783 {
8784 // Screen saver enabled for now.
8785 clear_keybuf();
8786 scare_mouse();
8787 Matrix(ss_speed, ss_density, 0);
8788 system_pal();
8789 unscare_mouse();
8790 broadcast_dialog_message(MSG_DRAW, 0);
8791 }
8792
8793 update_hw_screen();
8794 }
8795 while(update_dialog(p));
8796
8797 screen = oldscreen;
8798
8799 // font=oldfont;
8800 mouse_down=gui_mouse_b();
8801 shutdown_dialog(p);
8802 show_mouse(NULL);
8803 MenuOpen = false;
8804 if(Quit)
8805 {
8806 kill_sfx();
8807 music_stop();
8808 update_hw_screen();
8809 }
8810 else
8811 {
8812 game_pal();
8813 music_resume();
8814 resume_all_sfx();
8815
8816 if(rc)
8817 ringcolor(false);
8818 }
8819
8820 eat_buttons();
8821
8822 rc=false;
8823 clear_keybuf();
8824 // text_mode(0);
8825 }
8826
8827 14 void fix_dialogs()
8828 {
8829 14 jwin_center_dialog(about_dlg);
8830 14 jwin_center_dialog(gamepad_dlg);
8831 14 jwin_center_dialog(credits_dlg);
8832 14 jwin_center_dialog(gamemode_dlg);
8833 14 jwin_center_dialog(getnum_dlg);
8834 14 jwin_center_dialog(goto_dlg);
8835 14 jwin_center_dialog(keyboard_control_dlg);
8836 14 jwin_center_dialog(midi_dlg);
8837 14 jwin_center_dialog(quest_dlg);
8838 14 jwin_center_dialog(scrsaver_dlg);
8839 14 jwin_center_dialog(sound_dlg);
8840 14 jwin_center_dialog(triforce_dlg);
8841
8842 // digi_dp[1] += scrx;
8843 // digi_dp[2] += scry;
8844 // midi_dp[1] += scrx;
8845 // midi_dp[2] += scry;
8846 // pan_dp[1] += scrx;
8847 // pan_dp[2] += scry;
8848 // emus_dp[1] += scrx;
8849 // emus_dp[2] += scry;
8850 // buf_dp[1] += scrx;
8851 // buf_dp[2] += scry;
8852 // sfx_dp[1] += scrx;
8853 // sfx_dp[2] += scry;
8854 14 }
8855
8856 /*****************************/
8857 /**** Custom Sound System ****/
8858 /*****************************/
8859
8860 1052 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8861 {
8862
3/4
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1052 times.
✗ Branch 3 not taken.
1052 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8863 }
8864
8865 // Run an NSF, or a MIDI if the NSF is missing somehow.
8866 55 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8867 {
8868 55 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8869
8870 // Found it
8871
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 20 times.
55 if(newzcmusic!=NULL)
8872 {
8873 35 zcmusic_stop(zcmusic);
8874 35 zcmusic_unload_file(zcmusic);
8875 35 zc_stop_midi();
8876
8877 35 zcmusic=newzcmusic;
8878 35 zcmusic_play(zcmusic, emusic_volume);
8879
8880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(track>0)
8881 35 zcmusic_change_track(zcmusic,track);
8882
8883 35 return true;
8884 }
8885
8886 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8887
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 else if(midi>-1000)
8888 jukebox(midi);
8889
8890 20 return false;
8891 55 }
8892
8893 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8894 {
8895 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8896 // Found it
8897 if(newzcmusic!=NULL)
8898 {
8899 zcmusic_stop(zcmusic);
8900 zcmusic_unload_file(zcmusic);
8901 zc_stop_midi();
8902
8903 zcmusic=newzcmusic;
8904 zcmusic_play(zcmusic, emusic_volume);
8905
8906 if(track>0)
8907 zcmusic_change_track(zcmusic,track);
8908
8909 return true;
8910 }
8911
8912 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8913 else if(midi>-1000)
8914 jukebox(midi);
8915
8916 return false;
8917 }
8918
8919 int32_t get_zcmusicpos()
8920 {
8921 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8922 return debugtracething;
8923 return 0;
8924 }
8925
8926 void set_zcmusicpos(int32_t position)
8927 {
8928 zcmusic_set_curpos(zcmusic, position);
8929 }
8930
8931 void set_zcmusicspeed(int32_t speed)
8932 {
8933 int32_t newspeed = vbound(speed, 0, 10000);
8934 zcmusic_set_speed(zcmusic, newspeed);
8935 }
8936
8937 519 void jukebox(int32_t index,int32_t loop)
8938 {
8939 519 music_stop();
8940
8941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519 times.
519 if(index<0) index=MAXMIDIS-1;
8942
8943
1/2
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
519 if(index>=MAXMIDIS) index=0;
8944
8945 519 music_stop();
8946
8947 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8948 // stuck notes when a song stops. This fixes it.
8949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519 times.
519 if(strcmp(midi_driver->name, "DIGMID")==0)
8950 zc_set_volume(0, 0);
8951
8952 519 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8953 519 zc_play_midi((MIDI*)tunes[index].data,loop);
8954
8955
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 138 times.
519 if(tunes[index].start>0)
8956 138 zc_midi_seek(tunes[index].start);
8957
8958 519 midi_loop_start = tunes[index].loop_start;
8959 519 midi_loop_end = tunes[index].loop_end;
8960
8961 519 currmidi=index;
8962 519 master_volume(digi_volume,midi_volume);
8963 519 midi_paused=false;
8964 519 }
8965
8966 3833 void jukebox(int32_t index)
8967 {
8968
1/2
✓ Branch 0 taken 3833 times.
✗ Branch 1 not taken.
3833 if(index<0) index=MAXMIDIS-1;
8969
8970
1/2
✓ Branch 0 taken 3833 times.
✗ Branch 1 not taken.
3833 if(index>=MAXMIDIS) index=0;
8971
8972 // do nothing if it's already playing
8973
3/4
✓ Branch 0 taken 3314 times.
✓ Branch 1 taken 519 times.
✓ Branch 2 taken 3314 times.
✗ Branch 3 not taken.
3833 if(index==currmidi && midi_pos>=0)
8974 {
8975 3314 midi_paused=false;
8976 3314 return;
8977 }
8978
8979 519 jukebox(index,tunes[index].loop);
8980 3833 }
8981
8982 4485 void play_DmapMusic()
8983 {
8984 static char tfile[2048];
8985 static int32_t ttrack=0;
8986 4485 bool domidi=false;
8987
8988
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 3732 times.
4485 if(DMaps[currdmap].tmusic[0]!=0)
8989 {
8990
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1138 if(zcmusic==NULL ||
8991
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8992
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8993 {
8994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(zcmusic != NULL)
8995 {
8996 zcmusic_stop(zcmusic);
8997 zcmusic_unload_file(zcmusic);
8998 zcmusic = NULL;
8999 }
9000
9001 368 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9002
9003
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 282 times.
368 if(zcmusic!=NULL)
9004 {
9005 86 zc_stop_midi();
9006 86 strcpy(tfile,DMaps[currdmap].tmusic);
9007 86 zcmusic_play(zcmusic, emusic_volume);
9008 86 int32_t temptracks=0;
9009 86 temptracks=zcmusic_get_tracks(zcmusic);
9010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
9011 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9012 86 zcmusic_change_track(zcmusic,ttrack);
9013 86 }
9014 else
9015 {
9016 282 tfile[0] = 0;
9017 282 domidi=true;
9018 }
9019 368 }
9020 753 }
9021 else
9022 {
9023 3732 domidi=true;
9024 }
9025
9026
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 4014 times.
4485 if(domidi)
9027 {
9028 4014 int32_t m=DMaps[currdmap].midi;
9029
9030
3/4
✓ Branch 0 taken 3923 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
4014 switch(m)
9031 {
9032 case 1:
9033 81 jukebox(ZC_MIDI_OVERWORLD);
9034 81 break;
9035
9036 case 2:
9037 10 jukebox(ZC_MIDI_DUNGEON);
9038 10 break;
9039
9040 case 3:
9041 jukebox(ZC_MIDI_LEVEL9);
9042 break;
9043
9044 default:
9045
3/4
✓ Branch 0 taken 3631 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3631 times.
3923 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9046 3631 jukebox(m+MIDIOFFSET_DMAP);
9047 else
9048 292 music_stop();
9049 3923 }
9050 4014 }
9051 4485 }
9052
9053 4517 void playLevelMusic()
9054 {
9055 4517 int32_t m=tmpscr->screen_midi;
9056
9057
3/6
✓ Branch 0 taken 4469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
4517 switch(m)
9058 {
9059 case -2:
9060 11 music_stop();
9061 11 break;
9062
9063 case -1:
9064 4469 play_DmapMusic();
9065 4469 break;
9066
9067 case 1:
9068 jukebox(ZC_MIDI_OVERWORLD);
9069 break;
9070
9071 case 2:
9072 jukebox(ZC_MIDI_DUNGEON);
9073 break;
9074
9075 case 3:
9076 jukebox(ZC_MIDI_LEVEL9);
9077 break;
9078
9079 default:
9080
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9081 37 jukebox(m+MIDIOFFSET_MAPSCR);
9082 else
9083 music_stop();
9084 37 }
9085 4517 }
9086
9087 533 void master_volume(int32_t dv,int32_t mv)
9088 {
9089
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9090
9091
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9092
9093
6/6
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 532 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 517 times.
✓ Branch 5 taken 15 times.
533 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9094 533 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9095 533 }
9096
9097 /*****************/
9098 /***** SFX *****/
9099 /*****************/
9100
9101 // array of voices, one for each sfx sample in the data file
9102 // 0+ = voice #
9103 // -1 = voice not allocated
9104 14 void Z_init_sound()
9105 {
9106
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<WAV_COUNT; i++)
9107 3584 sfx_voice[i]=-1;
9108
9109
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 14 times.
112 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9110 98 tunes[i].data = (MIDI*)mididata[i].dat;
9111
9112
2/2
✓ Branch 0 taken 3528 times.
✓ Branch 1 taken 14 times.
3542 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9113 3528 tunes[ZC_MIDI_COUNT+j].data=NULL;
9114
9115 14 master_volume(digi_volume,midi_volume);
9116 14 }
9117
9118 // returns number of voices currently allocated
9119 int32_t sfx_count()
9120 {
9121 int32_t c=0;
9122
9123 for(int32_t i=0; i<WAV_COUNT; i++)
9124 if(sfx_voice[i]!=-1)
9125 ++c;
9126
9127 return c;
9128 }
9129
9130 // clean up finished samples
9131 3535881 void sfx_cleanup()
9132 {
9133
2/2
✓ Branch 0 taken 905185536 times.
✓ Branch 1 taken 3535881 times.
908721417 for(int32_t i=0; i<WAV_COUNT; i++)
9134
3/4
✓ Branch 0 taken 343184 times.
✓ Branch 1 taken 904842352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 343184 times.
905528720 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9135 {
9136 343184 deallocate_voice(sfx_voice[i]);
9137 343184 sfx_voice[i]=-1;
9138 343184 }
9139 3535881 }
9140
9141 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9142 // if a voice is already allocated (and/or playing), then it just returns true
9143 // Returns true: voice is allocated
9144 // false: unsuccessful
9145 430353 bool sfx_init(int32_t index)
9146 {
9147 // check index
9148
3/4
✓ Branch 0 taken 377965 times.
✓ Branch 1 taken 52388 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 377965 times.
430353 if(index<=0 || index>=WAV_COUNT)
9149 52388 return false;
9150
9151
2/2
✓ Branch 0 taken 34762 times.
✓ Branch 1 taken 343203 times.
377965 if(sfx_voice[index]==-1)
9152 {
9153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 343203 times.
343203 if(sfxdat)
9154 {
9155 if(index<Z35)
9156 {
9157 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9158 }
9159 else
9160 {
9161 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9162 }
9163 }
9164 else
9165 {
9166 343203 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9167 }
9168
9169 343203 voice_set_volume(sfx_voice[index], sfx_volume);
9170 343203 }
9171
9172 377965 return sfx_voice[index] != -1;
9173 430353 }
9174
9175 // plays an sfx sample
9176 375617 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9177 {
9178
2/2
✓ Branch 0 taken 349879 times.
✓ Branch 1 taken 25738 times.
375617 if(!sfx_init(index))
9179 25738 return;
9180
9181 349879 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9182 349879 voice_set_pan(sfx_voice[index],pan);
9183
9184 349879 int32_t pos = voice_get_position(sfx_voice[index]);
9185
9186
2/2
✓ Branch 0 taken 190793 times.
✓ Branch 1 taken 159086 times.
349879 if(restart) voice_set_position(sfx_voice[index],0);
9187
9188
1/2
✓ Branch 0 taken 349879 times.
✗ Branch 1 not taken.
349879 if(pos<=0)
9189 349879 voice_start(sfx_voice[index]);
9190 375617 }
9191
9192 // true if sfx is allocated
9193 5 bool sfx_allocated(int32_t index)
9194 {
9195
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9196 }
9197
9198 // start it (in loop mode) if it's not already playing,
9199 // otherwise adjust it to play in loop mode -DD
9200 54736 void cont_sfx(int32_t index)
9201 {
9202
2/2
✓ Branch 0 taken 26650 times.
✓ Branch 1 taken 28086 times.
54736 if(!sfx_init(index))
9203 {
9204 26650 return;
9205 }
9206
9207
1/2
✓ Branch 0 taken 28086 times.
✗ Branch 1 not taken.
28086 if(voice_get_position(sfx_voice[index])<=0)
9208 {
9209 28086 voice_set_position(sfx_voice[index],0);
9210 28086 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9211 28086 voice_start(sfx_voice[index]);
9212 28086 }
9213 else
9214 {
9215 adjust_sfx(index, 128, true);
9216 }
9217 54736 }
9218
9219 // adjust parameters while playing
9220 2480 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9221 {
9222
5/6
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 1104 times.
✓ Branch 2 taken 1376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1366 times.
2480 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9223 2470 return;
9224
9225 10 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9226 10 voice_set_pan(sfx_voice[index],pan);
9227 2480 }
9228
9229 // pauses a voice
9230 877 void pause_sfx(int32_t index)
9231 {
9232
3/6
✓ Branch 0 taken 877 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 877 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 877 times.
877 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9233 voice_stop(sfx_voice[index]);
9234 877 }
9235
9236 // resumes a voice
9237 418 void resume_sfx(int32_t index)
9238 {
9239
3/6
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
418 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9240 voice_start(sfx_voice[index]);
9241 418 }
9242
9243 // pauses all active voices
9244 59 void pause_all_sfx()
9245 {
9246
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 59 times.
15163 for(int32_t i=0; i<WAV_COUNT; i++)
9247
2/2
✓ Branch 0 taken 15102 times.
✓ Branch 1 taken 2 times.
15106 if(sfx_voice[i]!=-1)
9248 2 voice_stop(sfx_voice[i]);
9249 59 }
9250
9251 // resumes all paused voices
9252 45 void resume_all_sfx()
9253 {
9254
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 45 times.
11565 for(int32_t i=0; i<WAV_COUNT; i++)
9255
1/2
✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
11520 if(sfx_voice[i]!=-1)
9256 voice_start(sfx_voice[i]);
9257 45 }
9258
9259 // stops an sfx and deallocates the voice
9260 2847175 void stop_sfx(int32_t index)
9261 {
9262
3/4
✓ Branch 0 taken 2761303 times.
✓ Branch 1 taken 85872 times.
✓ Branch 2 taken 2761303 times.
✗ Branch 3 not taken.
2847175 if(index<=0 || index>=WAV_COUNT)
9263 85872 return;
9264
9265
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2761290 times.
2761303 if(sfx_voice[index]!=-1)
9266 {
9267 13 deallocate_voice(sfx_voice[index]);
9268 13 sfx_voice[index]=-1;
9269 13 }
9270 2847175 }
9271
9272 // Stops SFX played by Hero's item of the given family
9273 4396 void stop_item_sfx(int32_t family)
9274 {
9275 4396 int32_t id=current_item_id(family);
9276
9277
2/2
✓ Branch 0 taken 4154 times.
✓ Branch 1 taken 242 times.
4396 if(id<0)
9278 4154 return;
9279
9280 242 stop_sfx(itemsbuf[id].usesound);
9281 4396 }
9282
9283 903 void kill_sfx()
9284 {
9285
2/2
✓ Branch 0 taken 231168 times.
✓ Branch 1 taken 903 times.
232071 for(int32_t i=0; i<WAV_COUNT; i++)
9286
2/2
✓ Branch 0 taken 231162 times.
✓ Branch 1 taken 6 times.
231174 if(sfx_voice[i]!=-1)
9287 {
9288 6 deallocate_voice(sfx_voice[i]);
9289 6 sfx_voice[i]=-1;
9290 6 }
9291 903 }
9292
9293 321176 int32_t pan(int32_t x)
9294 {
9295
1/4
✓ Branch 0 taken 321176 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
321176 switch(pan_style)
9296 {
9297 case 0:
9298 return 128;
9299
9300 case 1:
9301 321176 return vbound((x>>1)+68,0,255);
9302
9303 case 2:
9304 return vbound(((x*3)>>2)+36,0,255);
9305 }
9306
9307 return vbound(x,0,255);
9308 321176 }
9309
9310 /*******************************/
9311 /******* Input Handlers ********/
9312 /*******************************/
9313
9314 7197284 bool joybtn(int32_t b)
9315 {
9316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7197284 times.
7197284 if(b == 0)
9317 return false;
9318
9319 7197284 return joy[joystick_index].button[b-1].b !=0;
9320 7197284 }
9321
9322 const char* joybtn_name(int32_t b)
9323 {
9324 if(b == 0)
9325 return "";
9326
9327 return joy[joystick_index].button[b-1].name;
9328 }
9329
9330 int32_t next_press_key()
9331 {
9332 return readkey()>>8;
9333 }
9334
9335 int32_t next_press_btn()
9336 {
9337 clear_keybuf();
9338 /*bool b[joy[joystick_index].num_buttons+1];
9339
9340 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9341 b[i]=joybtn(i);*/
9342
9343 //first, we need to wait until they're pressing no buttons
9344 for(;;)
9345 {
9346 if(keypressed())
9347 {
9348 switch(readkey()>>8)
9349 {
9350 case KEY_ESC:
9351 return -1;
9352
9353 case KEY_SPACE:
9354 return 0;
9355 }
9356 }
9357
9358 poll_joystick();
9359 bool done = true;
9360
9361 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9362 {
9363 if(joybtn(i)) done = false;
9364 }
9365
9366 if(done) break;
9367 rest(1);
9368 }
9369
9370 //now, we need to wait for them to press any button
9371 for(;;)
9372 {
9373 if(keypressed())
9374 {
9375 switch(readkey()>>8)
9376 {
9377 case KEY_ESC:
9378 return -1;
9379
9380 case KEY_SPACE:
9381 return 0;
9382 }
9383 }
9384
9385 poll_joystick();
9386
9387 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9388 {
9389 if(joybtn(i)) return i;
9390 }
9391 rest(1);
9392 }
9393 }
9394
9395 71769032 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9396 {
9397
2/2
✓ Branch 0 taken 69111742 times.
✓ Branch 1 taken 2657290 times.
71769032 bool ret = btn && !flag;
9398
2/2
✓ Branch 0 taken 71674853 times.
✓ Branch 1 taken 94179 times.
71769032 flag = rawbtn ? *rawbtn : btn;
9399
9400 71769032 return ret;
9401 }
9402 864 static bool rButtonPeek(bool btn, bool flag)
9403 {
9404
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9405 {
9406 828 return false;
9407 }
9408
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9409 {
9410 9 return true;
9411 }
9412
9413 27 return false;
9414 864 }
9415
9416 // Updated only by keyboard/gamepad.
9417 // If in replay mode, this is set directly by the replay system.
9418 // This should never be read from directly - use control_state instead.
9419 bool raw_control_state[ZC_CONTROL_STATES];
9420
9421 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9422 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9423 // lasts until the next call to load_control_state.
9424 bool control_state[ZC_CONTROL_STATES];
9425 bool disable_control[ZC_CONTROL_STATES];
9426 bool drunk_toggle_state[11];
9427 bool disabledKeys[127];
9428 bool KeyInput[127];
9429 bool KeyPress[127];
9430
9431 bool key_current_frame[127];
9432 bool key_previous_frame[127];
9433
9434 static bool key_system[127];
9435 static bool key_system_previous[127];
9436 static bool key_system_press[127];
9437
9438 bool button_press[ZC_CONTROL_STATES];
9439 bool button_hold[ZC_CONTROL_STATES];
9440
9441 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9442 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9443 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9444 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9445 #define STICK_PRECISION 56 //define your own sensitivity
9446
9447 2884925 void load_control_state()
9448 {
9449
4/4
✓ Branch 0 taken 2884922 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13721 times.
✓ Branch 3 taken 2871201 times.
2884925 if (!replay_is_active() || replay_get_version() >= 8)
9450 {
9451
2/2
✓ Branch 0 taken 247032 times.
✓ Branch 1 taken 13724 times.
260756 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9452 247032 down_control_states[i] = raw_control_state[i];
9453 13724 }
9454
9455
1/2
✓ Branch 0 taken 2884925 times.
✗ Branch 1 not taken.
2884925 if (!replay_is_replaying())
9456 {
9457 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9458 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9459 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9460 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9461 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9462 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9463 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9464 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9465 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9466 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9467 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9468 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9469 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9470 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9471
9472 if(num_joysticks != 0)
9473 {
9474 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9475 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9476 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9477 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9478 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9479 }
9480 else
9481 {
9482 raw_control_state[14] = false;
9483 raw_control_state[15] = false;
9484 raw_control_state[16] = false;
9485 raw_control_state[17] = false;
9486 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9487 }
9488 }
9489
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2884922 times.
2884925 if (replay_is_active())
9490 {
9491
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 1869707 times.
2884922 if (replay_get_version() < 3)
9492 1015215 replay_poll();
9493
3/4
✓ Branch 0 taken 1869707 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108332 times.
✓ Branch 3 taken 1761375 times.
1869707 else if (replay_is_replaying() && replay_get_version() < 6)
9494 1761375 replay_peek_input();
9495
3/4
✓ Branch 0 taken 108332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94608 times.
✓ Branch 3 taken 13724 times.
108332 else if (replay_is_replaying() && replay_get_version() >= 8)
9496 13724 replay_peek_input();
9497 2884922 }
9498
9499
3/4
✓ Branch 0 taken 2884919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✓ Branch 3 taken 2871195 times.
2884925 if (!replay_is_active() || replay_get_version() >= 8)
9500 13724 update_keys();
9501
9502 // Some test replay files were made before a serious input bug was fixed, so instead
9503 // of re-doing them or tossing them out, just check for that zplay version.
9504
3/4
✓ Branch 0 taken 2884919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 2763019 times.
2884919 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9505
2/2
✓ Branch 0 taken 2884919 times.
✓ Branch 1 taken 51928542 times.
54813461 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9506 {
9507 51928542 control_state[i] = raw_control_state[i];
9508
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 2441232 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
51928542 if (botched_input && !control_state[i])
9509 47077142 down_control_states[i] = false;
9510 51928542 }
9511
9512 2884919 button_press[0]=rButton(control_state[0],button_hold[0]);
9513 2884919 button_press[1]=rButton(control_state[1],button_hold[1]);
9514 2884919 button_press[2]=rButton(control_state[2],button_hold[2]);
9515 2884919 button_press[3]=rButton(control_state[3],button_hold[3]);
9516 2884919 button_press[4]=rButton(control_state[4],button_hold[4]);
9517 2884919 button_press[5]=rButton(control_state[5],button_hold[5]);
9518 2884919 button_press[6]=rButton(control_state[6],button_hold[6]);
9519 2884919 button_press[7]=rButton(control_state[7],button_hold[7]);
9520 2884919 button_press[8]=rButton(control_state[8],button_hold[8]);
9521 2884919 button_press[9]=rButton(control_state[9],button_hold[9]);
9522 2884919 button_press[10]=rButton(control_state[10],button_hold[10]);
9523 2884919 button_press[11]=rButton(control_state[11],button_hold[11]);
9524 2884919 button_press[12]=rButton(control_state[12],button_hold[12]);
9525 2884919 button_press[13]=rButton(control_state[13],button_hold[13]);
9526 2884919 button_press[14]=rButton(control_state[14],button_hold[14]);
9527 2884919 button_press[15]=rButton(control_state[15],button_hold[15]);
9528 2884919 button_press[16]=rButton(control_state[16],button_hold[16]);
9529 2884919 button_press[17]=rButton(control_state[17],button_hold[17]);
9530 2884919 }
9531
9532 // Returns true if any game key is pressed. This is needed because keypressed()
9533 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9534 14382463 bool zc_key_pressed()
9535 //may also need to use zc_getrawkey
9536 {
9537
7/10
✓ Branch 0 taken 11493103 times.
✓ Branch 1 taken 2889360 times.
✓ Branch 2 taken 2889360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2889360 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2406575 times.
✓ Branch 7 taken 2406575 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699241 times.
15081704 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9538
4/6
✓ Branch 0 taken 2406575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2406575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1771782 times.
✓ Branch 5 taken 1771782 times.
2406575 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9539
4/6
✓ Branch 0 taken 1771782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1771782 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1090021 times.
✓ Branch 5 taken 1090021 times.
1771782 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9540
4/6
✓ Branch 0 taken 1090021 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1090021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 827163 times.
✓ Branch 5 taken 827163 times.
1090021 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9541
1/2
✓ Branch 0 taken 827163 times.
✗ Branch 1 not taken.
827163 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9542
3/4
✓ Branch 0 taken 756665 times.
✓ Branch 1 taken 70498 times.
✓ Branch 2 taken 756665 times.
✗ Branch 3 not taken.
827163 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9543
3/4
✓ Branch 0 taken 709752 times.
✓ Branch 1 taken 46913 times.
✓ Branch 2 taken 709752 times.
✗ Branch 3 not taken.
756665 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9544
3/4
✓ Branch 0 taken 705894 times.
✓ Branch 1 taken 3858 times.
✓ Branch 2 taken 705894 times.
✗ Branch 3 not taken.
709752 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9545
3/4
✓ Branch 0 taken 700077 times.
✓ Branch 1 taken 5817 times.
✓ Branch 2 taken 700077 times.
✗ Branch 3 not taken.
705894 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9546
3/4
✓ Branch 0 taken 700026 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 700026 times.
✗ Branch 3 not taken.
700077 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9547
3/4
✓ Branch 0 taken 699984 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 699984 times.
✗ Branch 3 not taken.
700026 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9548
3/4
✓ Branch 0 taken 699241 times.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 699241 times.
✗ Branch 3 not taken.
699984 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9549
2/4
✓ Branch 0 taken 699241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 699241 times.
✗ Branch 3 not taken.
699241 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9550
1/2
✓ Branch 0 taken 699241 times.
✗ Branch 1 not taken.
699241 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9551 25874304 return true;
9552
9553 699241 return false;
9554 3587339 }
9555
9556 58028487 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9557 {
9558 58028487 bool ret = false, drunkstate = false, rawret = false;
9559 58028487 bool* flag = &down_control_states[btn];
9560
2/7
✓ Branch 0 taken 54437014 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3591473 times.
58028487 switch(btn)
9561 {
9562 case btnF12:
9563 ret = zc_getkey(KEY_F12, ignoreDisable);
9564 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9565 eatEntirely = false;
9566 break;
9567 case btnF11:
9568 ret = zc_getkey(KEY_F11, ignoreDisable);
9569 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9570 eatEntirely = false;
9571 break;
9572 case btnF5:
9573 ret = zc_getkey(KEY_F5, ignoreDisable);
9574 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9575 eatEntirely = false;
9576 break;
9577 case btnQ:
9578 ret = zc_getkey(KEY_Q, ignoreDisable);
9579 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9580 eatEntirely = false;
9581 break;
9582 case btnI:
9583 ret = zc_getkey(KEY_I, ignoreDisable);
9584 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9585 eatEntirely = false;
9586 break;
9587 case btnM:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3591473 times.
3591473 if(FFCore.kb_typing_mode) return false;
9589 3591473 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9590 3591473 eatEntirely = false;
9591 3591473 break;
9592 default: //control_state[] index
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54437014 times.
54437014 if(FFCore.kb_typing_mode) return false;
9594
5/6
✓ Branch 0 taken 54372280 times.
✓ Branch 1 taken 64734 times.
✓ Branch 2 taken 1875887 times.
✓ Branch 3 taken 52496393 times.
✓ Branch 4 taken 1875887 times.
✗ Branch 5 not taken.
54437014 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9595
2/2
✓ Branch 0 taken 2993228 times.
✓ Branch 1 taken 51443786 times.
54437014 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9596
4/4
✓ Branch 0 taken 48582368 times.
✓ Branch 1 taken 5854646 times.
✓ Branch 2 taken 978 times.
✓ Branch 3 taken 5853668 times.
60291660 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9597 54437014 rawret = raw_control_state[btn];
9598 54437014 }
9599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58028487 times.
58028487 assert(flag);
9600
2/2
✓ Branch 0 taken 38187133 times.
✓ Branch 1 taken 19841354 times.
58028487 if(press)
9601 {
9602
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 19840490 times.
19841354 if(peek)
9603 864 ret = rButtonPeek(ret, *flag);
9604
3/4
✓ Branch 0 taken 19840490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94179 times.
✓ Branch 3 taken 19746311 times.
19840490 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9605 94179 else ret = rButton(ret, *flag, &rawret);
9606 19841354 }
9607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58028487 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58028487 if(eatEntirely && ret) control_state[btn] = false;
9608
3/4
✓ Branch 0 taken 44769876 times.
✓ Branch 1 taken 13258611 times.
✓ Branch 2 taken 44769876 times.
✗ Branch 3 not taken.
58028487 if(drunk && drunkstate) ret = !ret;
9609 58028487 return ret;
9610 58028487 }
9611
9612 23568 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9613 {
9614 23568 byte ret = 0;
9615
2/2
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 864 times.
23568 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9616
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9617
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9618
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9619
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9620
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9621
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9622
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9623 23568 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9624 }
9625
9626 byte checkIntBtnVal(byte intbtn, byte vals)
9627 {
9628 return intbtn&vals;
9629 }
9630
9631 586553 bool Up()
9632 {
9633 586553 return getInput(btnUp);
9634 }
9635 13861 bool Down()
9636 {
9637 13861 return getInput(btnDown);
9638 }
9639 22110 bool Left()
9640 {
9641 22110 return getInput(btnLeft);
9642 }
9643 24589 bool Right()
9644 {
9645 24589 return getInput(btnRight);
9646 }
9647 24305 bool cAbtn()
9648 {
9649 24305 return getInput(btnA);
9650 }
9651 523195 bool cBbtn()
9652 {
9653 523195 return getInput(btnB);
9654 }
9655 bool cSbtn()
9656 {
9657 return getInput(btnS);
9658 }
9659 296 bool cLbtn()
9660 {
9661 296 return getInput(btnL);
9662 }
9663 296 bool cRbtn()
9664 {
9665 296 return getInput(btnR);
9666 }
9667 bool cPbtn()
9668 {
9669 return getInput(btnP);
9670 }
9671 bool cEx1btn()
9672 {
9673 return getInput(btnEx1);
9674 }
9675 bool cEx2btn()
9676 {
9677 return getInput(btnEx2);
9678 }
9679 bool cEx3btn()
9680 {
9681 return getInput(btnEx3);
9682 }
9683 bool cEx4btn()
9684 {
9685 return getInput(btnEx4);
9686 }
9687 bool AxisUp()
9688 {
9689 return getInput(btnAxisUp);
9690 }
9691 bool AxisDown()
9692 {
9693 return getInput(btnAxisDown);
9694 }
9695 bool AxisLeft()
9696 {
9697 return getInput(btnAxisLeft);
9698 }
9699 bool AxisRight()
9700 {
9701 return getInput(btnAxisRight);
9702 }
9703
9704 bool cMbtn()
9705 {
9706 return getInput(btnM);
9707 }
9708 bool cF12()
9709 {
9710 return getInput(btnF12);
9711 }
9712 bool cF11()
9713 {
9714 return getInput(btnF11);
9715 }
9716 bool cF5()
9717 {
9718 return getInput(btnF5);
9719 }
9720 bool cQ()
9721 {
9722 return getInput(btnQ);
9723 }
9724 bool cI()
9725 {
9726 return getInput(btnI);
9727 }
9728
9729 50999 bool rUp()
9730 {
9731 50999 return getInput(btnUp, true);
9732 }
9733 50956 bool rDown()
9734 {
9735 50956 return getInput(btnDown, true);
9736 }
9737 50944 bool rLeft()
9738 {
9739 50944 return getInput(btnLeft, true);
9740 }
9741 50544 bool rRight()
9742 {
9743 50544 return getInput(btnRight, true);
9744 }
9745 310 bool rAbtn()
9746 {
9747 310 return getInput(btnA, true);
9748 }
9749 51309 bool rBbtn()
9750 {
9751 51309 return getInput(btnB, true);
9752 }
9753 2859197 bool rSbtn()
9754 {
9755 2859197 return getInput(btnS, true);
9756 }
9757 3587339 bool rMbtn()
9758 {
9759 3587339 return getInput(btnM, true);
9760 }
9761 50395 bool rLbtn()
9762 {
9763 50395 return getInput(btnL, true);
9764 }
9765 50392 bool rRbtn()
9766 {
9767 50392 return getInput(btnR, true);
9768 }
9769 2807837 bool rPbtn()
9770 {
9771 2807837 return getInput(btnP, true);
9772 }
9773 bool rEx1btn()
9774 {
9775 return getInput(btnEx1, true);
9776 }
9777 bool rEx2btn()
9778 {
9779 return getInput(btnEx2, true);
9780 }
9781 50952 bool rEx3btn()
9782 {
9783 50952 return getInput(btnEx3, true);
9784 }
9785 50952 bool rEx4btn()
9786 {
9787 50952 return getInput(btnEx4, true);
9788 }
9789 bool rAxisUp()
9790 {
9791 return getInput(btnAxisUp, true);
9792 }
9793 bool rAxisDown()
9794 {
9795 return getInput(btnAxisDown, true);
9796 }
9797 bool rAxisLeft()
9798 {
9799 return getInput(btnAxisLeft, true);
9800 }
9801 bool rAxisRight()
9802 {
9803 return getInput(btnAxisRight, true);
9804 }
9805
9806 bool rF11()
9807 {
9808 return getInput(btnF11, true);
9809 }
9810 bool rQ()
9811 {
9812 return getInput(btnQ, true);
9813 }
9814 bool rI()
9815 {
9816 return getInput(btnI, true);
9817 }
9818
9819 7413711 bool DrunkUp()
9820 {
9821 7413711 return getInput(btnUp, false, true);
9822 }
9823 6910417 bool DrunkDown()
9824 {
9825 6910417 return getInput(btnDown, false, true);
9826 }
9827 4601221 bool DrunkLeft()
9828 {
9829 4601221 return getInput(btnLeft, false, true);
9830 }
9831 4069815 bool DrunkRight()
9832 {
9833 4069815 return getInput(btnRight, false, true);
9834 }
9835 3233302 bool DrunkcAbtn()
9836 {
9837 3233302 return getInput(btnA, false, true);
9838 }
9839 2866550 bool DrunkcBbtn()
9840 {
9841 2866550 return getInput(btnB, false, true);
9842 }
9843 2807240 bool DrunkcEx1btn()
9844 {
9845 2807240 return getInput(btnEx1, false, true);
9846 }
9847 2807260 bool DrunkcEx2btn()
9848 {
9849 2807260 return getInput(btnEx2, false, true);
9850 }
9851 bool DrunkcSbtn()
9852 {
9853 return getInput(btnS, false, true);
9854 }
9855 bool DrunkcMbtn()
9856 {
9857 return getInput(btnM, false, true);
9858 }
9859 bool DrunkcLbtn()
9860 {
9861 return getInput(btnL, false, true);
9862 }
9863 bool DrunkcRbtn()
9864 {
9865 return getInput(btnR, false, true);
9866 }
9867 bool DrunkcPbtn()
9868 {
9869 return getInput(btnP, false, true);
9870 }
9871
9872 bool DrunkrUp()
9873 {
9874 return getInput(btnUp, true, true);
9875 }
9876 bool DrunkrDown()
9877 {
9878 return getInput(btnDown, true, true);
9879 }
9880 bool DrunkrLeft()
9881 {
9882 return getInput(btnLeft, true, true);
9883 }
9884 bool DrunkrRight()
9885 {
9886 return getInput(btnRight, true, true);
9887 }
9888 2237746 bool DrunkrAbtn()
9889 {
9890 2237746 return getInput(btnA, true, true);
9891 }
9892 2235750 bool DrunkrBbtn()
9893 {
9894 2235750 return getInput(btnB, true, true);
9895 }
9896 71669 bool DrunkrEx1btn()
9897 {
9898 71669 return getInput(btnEx1, true, true);
9899 }
9900 71662 bool DrunkrEx2btn()
9901 {
9902 71662 return getInput(btnEx2, true, true);
9903 }
9904 bool DrunkrEx3btn()
9905 {
9906 return getInput(btnEx3, true, true);
9907 }
9908 bool DrunkrEx4btn()
9909 {
9910 return getInput(btnEx4, true, true);
9911 }
9912 bool DrunkrSbtn()
9913 {
9914 return getInput(btnS, true, true);
9915 }
9916 bool DrunkrMbtn()
9917 {
9918 return getInput(btnM, true, true);
9919 }
9920 2721936 bool DrunkrLbtn()
9921 {
9922 2721936 return getInput(btnL, true, true);
9923 }
9924 2720733 bool DrunkrRbtn()
9925 {
9926 2720733 return getInput(btnR, true, true);
9927 }
9928 bool DrunkrPbtn()
9929 {
9930 return getInput(btnP, true, true);
9931 }
9932
9933 4134 void eat_buttons()
9934 {
9935 4134 getInput(btnA, true, false, true);
9936 4134 getInput(btnB, true, false, true);
9937 4134 getInput(btnS, true, false, true);
9938 4134 getInput(btnM, true, false, true);
9939 4134 getInput(btnL, true, false, true);
9940 4134 getInput(btnR, true, false, true);
9941 4134 getInput(btnP, true, false, true);
9942 4134 getInput(btnEx1, true, false, true);
9943 4134 getInput(btnEx2, true, false, true);
9944 4134 getInput(btnEx3, true, false, true);
9945 4134 getInput(btnEx4, true, false, true);
9946 4134 }
9947
9948 // Is true for the _first frame_ of a key press.
9949 // But! it is possible that a script manually sets the value of KeyPress,
9950 // in which case it will be restored to the "true" value based on `key_current_frame`
9951 // and `key_previous_frame` on the next frame.
9952 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9953 {
9954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9956 {
9957 case KEY_F7:
9958 case KEY_F8:
9959 case KEY_F9:
9960 return KeyPress[k];
9961
9962 default:
9963
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9964 }
9965 14 }
9966
9967 // Is true for _every frame_ a key is held down.
9968 // But! it is possible that a script manually sets the value of KeyInput,
9969 // in which case it will be restored to the "true" value based on `key_current_frame`
9970 // on the next frame.
9971 bool zc_getkey(int32_t k, bool ignoreDisable)
9972 {
9973 if(ignoreDisable) return KeyInput[k];
9974 switch(k)
9975 {
9976 case KEY_F7:
9977 case KEY_F8:
9978 case KEY_F9:
9979 return KeyInput[k];
9980
9981 default:
9982 return KeyInput[k] && !disabledKeys[k];
9983 }
9984 }
9985
9986 // Reads (and then clears) the current frame key state directly.
9987 // Scripts can also modify `key_current_frame`.
9988 26768522 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9989 {
9990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26768522 times.
26768522 if(zc_getrawkey(k, ignoreDisable))
9991 {
9992 _key[k]=key[k]=key_current_frame[k]=0;
9993 return true;
9994 }
9995 26768522 _key[k]=key[k]=key_current_frame[k]=0;
9996 26768522 return false;
9997 26768522 }
9998
9999 // Reads the current frame key state directly.
10000 // Scripts can also modify `key_current_frame`.
10001 48603115 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10002 {
10003
2/2
✓ Branch 0 taken 18247268 times.
✓ Branch 1 taken 30355847 times.
48603115 if(ignoreDisable) return key_current_frame[k];
10004
2/2
✓ Branch 0 taken 13384240 times.
✓ Branch 1 taken 16971607 times.
30355847 switch(k)
10005 {
10006 case KEY_F7:
10007 case KEY_F8:
10008 case KEY_F9:
10009 13384240 return key_current_frame[k];
10010
10011 default:
10012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16971607 times.
16971607 return key_current_frame[k] && !disabledKeys[k];
10013 }
10014 48603115 }
10015
10016 // Only used for a handful of keys, like tilde and Function keys.
10017 // This state is never read within the game.
10018 // It exists so that all keyboard input still functions during replay,
10019 // without inadvertently doing things like toggling throttling if the player
10020 // presses ~
10021 7072371 bool zc_get_system_key(int32_t k)
10022 {
10023 7072371 return key_system[k];
10024 }
10025
10026 // True for the _first_ frame of a key press.
10027 39460729 bool zc_read_system_key(int32_t k)
10028 {
10029 39460729 return key_system_press[k];
10030 }
10031
10032 455592053 bool is_system_key(int32_t k)
10033 {
10034
2/2
✓ Branch 0 taken 423306002 times.
✓ Branch 1 taken 32286051 times.
455592053 switch (k)
10035 {
10036 case KEY_BACKQUOTE:
10037 case KEY_CLOSEBRACE:
10038 case KEY_END:
10039 case KEY_HOME:
10040 case KEY_OPENBRACE:
10041 case KEY_PGDN:
10042 case KEY_PGUP:
10043 case KEY_TAB:
10044 case KEY_TILDE:
10045 32286051 return true;
10046 }
10047 423306002 return is_Fkey(k);
10048 455592053 }
10049
10050 3587339 void update_system_keys()
10051 {
10052 3587339 poll_keyboard();
10053
2/2
✓ Branch 0 taken 455592053 times.
✓ Branch 1 taken 3587339 times.
459179392 for (int32_t q = 0; q < 127; ++q)
10054 {
10055
2/2
✓ Branch 0 taken 75334119 times.
✓ Branch 1 taken 380257934 times.
455592053 if (!is_system_key(q))
10056 380257934 continue;
10057
10058 75334119 key_system[q] = key[q];
10059
1/2
✓ Branch 0 taken 75334119 times.
✗ Branch 1 not taken.
75334119 key_system_press[q] = key_system[q] && !key_system_previous[q];
10060 75334119 key_system_previous[q] = key_system[q];
10061 75334119 }
10062 3587339 }
10063
10064 3534911 void update_keys()
10065 {
10066
1/2
✓ Branch 0 taken 3534911 times.
✗ Branch 1 not taken.
3534911 if (!replay_is_replaying())
10067 poll_keyboard();
10068
10069
2/2
✓ Branch 0 taken 3534911 times.
✓ Branch 1 taken 448933697 times.
452468608 for (int32_t q = 0; q < 127; ++q)
10070 {
10071 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10072
1/2
✓ Branch 0 taken 448933697 times.
✗ Branch 1 not taken.
448933697 if (!replay_is_replaying())
10073 key_current_frame[q] = key[q];
10074
10075
2/2
✓ Branch 0 taken 445731779 times.
✓ Branch 1 taken 3201918 times.
448933697 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10076
4/4
✓ Branch 0 taken 113908 times.
✓ Branch 1 taken 448819789 times.
✓ Branch 2 taken 113907 times.
✓ Branch 3 taken 1 times.
448933697 if (KeyPress[q] && q == KEY_B) {
10077 1 int lol = 1;
10078 1 }
10079 448933697 KeyInput[q] = key_current_frame[q];
10080 448933697 key_previous_frame[q] = key_current_frame[q];
10081 448933697 }
10082 3534911 }
10083
10084 bool zc_disablekey(int32_t k, bool val)
10085 {
10086 switch(k)
10087 {
10088 case KEY_F7:
10089 case KEY_F8:
10090 case KEY_F9:
10091 return false;
10092
10093 default:
10094 disabledKeys[k] = val;
10095 return true;
10096 }
10097 }
10098
10099 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10100 {
10101 timer=timer;
10102 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10103 }
10104
10105 // these are here so that copy_dialog won't choke when compiling zelda
10106 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10107 {
10108 return D_O_K;
10109 }
10110
10111 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10112 {
10113 return D_O_K;
10114 }
10115
10116 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10117 {
10118 return D_O_K;
10119 }
10120
10121 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10122 {
10123 return D_O_K;
10124 }
10125
10126 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10127 {
10128 return D_O_K;
10129 }
10130
10131 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10132 {
10133 return D_O_K;
10134 }
10135
10136 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10137 {
10138 return D_O_K;
10139 }
10140
10141 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10142 {
10143 return D_O_K;
10144 }
10145
10146 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10147 {
10148 return D_O_K;
10149 }
10150
10151 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10152 {
10153 return D_O_K;
10154 }
10155
10156 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10157 {
10158 return D_O_K;
10159 }
10160
10161 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10162 {
10163 return D_O_K;
10164 }
10165
10166 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10167 {
10168 return D_O_K;
10169 }
10170
10171 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10172 {
10173 return D_O_K;
10174 }
10175
10176 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10177 {
10178 return D_O_K;
10179 }
10180
10181 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10182 {
10183 return D_O_K;
10184 }
10185
10186 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10187 {
10188 return D_O_K;
10189 }
10190
10191 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10192 {
10193 return D_O_K;
10194 }
10195
10196 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10197 {
10198 return D_O_K;
10199 }
10200
10201 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10202 {
10203 return D_O_K;
10204 }
10205
10206 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10207 {
10208 return D_O_K;
10209 }
10210
10211 /*** end of zc_sys.cc ***/
10212
10213